2

I would like to record a live stream to a sequence of mp4 on disk. I'm able to do one file like this:

ffmpeg -i rtmp://source.com/live/stream -r 5 -t 60 c:\test.mp4

This results in one 60s mp4 (test.mp4). What I would like is something like this:

ffmpeg -i rtmp://source.com/live/stream -r 5 -t 60 c:\test%d.mp4

That results in one 60s mp4 per minute (test1.mp4, test2.mp4, etc) I'm finding plenty of examples for extracting single frames in a similar way, but not video.

I realize I can just loop a call to the first example, but I was hoping there would be a good way to do it with minimal loss between each file by letting ffmpeg handle the sequencing. What is the cleanest way to record a live stream into a sequence of mp4?

9

You can use the segment muxer. Example command:

ffmpeg -i rtmp://source.com/live/stream -c copy -flags +global_header -f segment -segment_time 60 -segment_format_options movflags=+faststart -reset_timestamps 1 test%d.mp4
  • That is it exactly and you are amazing. Thanks! – Daniel Nov 12 '15 at 16:29
  • FYI - I found I needed to add -reset_timestamps 1 or the segments after the first one would not play correctly in most browsers. See this explanation: dahuatu.com/JVwakkLZyM.html – Daniel Nov 13 '15 at 2:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.