Schedule FFmpeg livestream recording with cron jobs

July 21st, 2014 by
First output the FFmpeg full path using the command:
which ffmpeg
That will will give you something like “/usr/local/bin/ffmpeg” then you set the cron job this way
* 5-19 * * * /usr/local/bin/ffmpeg -i http://serverip:1935/livestream -acodec copy -vcodec copy -t 5:00 /pathto/videoname.mp4 > /dev/null 2>&1
The 5-19 means that it will record on the top of the hours from 5am to 7pm. The -t value indicates the video recording duration, in this case -t 2:00 = 2 minutes. If you want to add the date and time of the recording to the file name use example $(date + \%Y-\%m-\%d)
* 5-19 * * * /usr/local/bin/ffmpeg -i http://serverip:1935/livestream -acodec copy -vcodec copy -t 5:00 /pathto/videoname-$(date +\%Y-\%m-\%d).mp4 > /dev/null 2>&1

Post a Comment

You must be logged in to post a comment.

Cached at: 2020-10-29 08:37:29am