ffmpeg capture RTSP stream to hourly file

10,321

output hourly video files

You can start ffmpeg over crontab every hour Ubuntu Crontab

0 * * * * ffmpeg -i rtsp://[IP Address]:[port]/[URL] -vcodec copy -r 60 -t 3540 -y $(date +\%Y\%m\%d\%H).mp4

add a text overlay

You can find more Information here ->https://stackoverflow.com/questions/17623676/text-on-video-ffmpeg

cleanup old files

Remove old videos -> Delete files older than 10 days using shell script in Unix

Share:
10,321
Admin
Author by

Admin

Updated on June 14, 2022

Comments

  • Admin
    Admin almost 2 years

    I'm using ffmpeg to capture a RTSP stream to a file using the following command:

    ffmpeg -i rtsp://[IP Address]:[port]/[URL] -vcodec copy -r 60 -t 2600 -y /[outputfile].mp4
    

    This works ok and captures 60 mins fine. What I'd like to be able to do is:

    1. Output hourly files, e.g. capture1.mp4 capture2.mp4 etc.
    2. Put the current timestamp as the overlay in the current file (currently VLC says something like LIVE555...). I'd like to change this to source + timestamp.
    3. Delete old mp4 files over x days old, e.g. keep files for 1 or 2 days

    Is this possible in ffmpeg or do i need to put a script wrapper around the ffmpeg command? If so, any examples of those I can re-use please? This is on Ubuntu linux using latest ffmpeg package and using apt-get install ffmpeg to install so it's built from source.

    Thanks