How to record audio of a stream radio at scheduled times with FFmpeg in CentOS?

0

I would like to do a similar service to censury.com.br, something that records my radio at certain times, in .mp3 files with different names according to the recording. EX: stream08-19-2019-22-00.mp3

I'm very new but ffmpeg sounds like the perfect way to record my favorite radio shows.

I like some specific times of three radios and a VPS with CentOS, to be able to record these programs would be amazing.

Rodrigo

Posted 2019-08-20T01:17:52.250

Reputation: 1

Answers

1

One time recording

You can use the at command do schedule a command or script:

at 14:30:00

A prompt will appear where you can enter your scheduled command:

at > ffmpeg -i input -t 01:00:00 -c copy "$(date +%F_%H-%M-%S).m4a"

The example above will record for one hour (-t 01:00:00).

To save press ctrl + d.

To view the scheduled job use the atq command.

Repetitive recording

You can use crontab to create cron jobs that will be executed on a periodic, fixed schedule:

crontab -e

Then enter your command:

0 16 * * 3 ffmpeg -i input -t 01:00:00 -c copy "$(date +%F_%H-%M-%S).m4a"

The above example will record every Wednesday at 16:00 for one hour (-t 01:00:00).

You can view your cron jobs with crontab -l.

llogan

Posted 2019-08-20T01:17:52.250

Reputation: 31 929

Hi, llogan. Thanks for you fast reply. I believe that for my need the best option is crontab.

Let's say I want to record this radio every Wednesday at 4:00 pm for an hour, would that be exactly the code?

0 2 * * wed ffmpeg -i https://c2901-slbps-sambavideos.akamaized.net/radio/FMoDiaAudio_14d480346fa04ebcb4f03173f2dae707/livestream/chunklist.m3u8 -t 01:00:00 -c copy radio.aac

– Rodrigo – 2019-08-21T02:03:44.847

In the case of another radio record every Saturday from 20:00 to 22:00.

0 20 * * sat ffmpeg -i http://167.114.103.39:8766/stream -t 02:00:00 -c copy anotherrecord.aac

– Rodrigo – 2019-08-21T02:06:51.213

In either case, how would I make the recording file names have names according to the day? – Rodrigo – 2019-08-21T02:08:00.123

@Rodrigo Answer updated to address follow-up questions. – llogan – 2019-08-21T17:42:23.507