5

I'm looking for a way to record a video UDP stream using ffmpeg but in 10mn chunks. I currently use the following to get 10mn of video (with h264 transcoding).

"ffmpeg -i udp://239.0.77.15:5000 -map 0:0 -map 0:1 -s 640x360 -vcodec libx264 -g 100 -vb 500000 -r 25 -strict experimental -vf yadif -acodec aac -ab 96000 -ac 2 -t 600 -y /media/test.m4 "

My problem is that using command line ffmpeg needs time to resync with the udp stream loosing 2 seconds of video each time. Is it normal ?

Any idea if there is a way to do it in command line or should I tried to use the ffmpeg API ?

Thanks in advance

2 Answers 2

14

Ok found it.

Recently ffmpeg add a segmenter, here is the syntax:

-f segment: tell ffmpeg to use the segmenter

-segment_time: chunk size in second

You can use autoincrement file name with something like %03d (000,001,002,003...).

Here is my line to transcode a UDP MPEGTS stream, into H264+AAC and save it to file chunk (60 seconds):

ffmpeg -i udp://239.0.77.15:5000 -map 0:0 -map 0:1 -s 640x360 -vcodec libx264 -g 60 -vb 500000 -strict experimental -vf yadif -acodec aac -ab 96000 -ac 2 -y -f segment -segment_time 60 "xxx-%03d.ts"

Sign up to request clarification or add additional context in comments.

2 Comments

I'm trying to use your solution, right now I have: ffmpeg -i rtsp://192.168.88.11/ -vcodec copy -acodec copy -f mp4 -segment_time 60 -y "test-%03d.mp4" This works fine, but the output is not in segments. If I replace the -f mp4 with -f segment, I get: Output file #0 does not contain any stream Any ideas?
Just wondering when converting+recording multiple UDP / RSTP streams to mp4 would that cause a lot of RAM usage? I want to try to experiment with 8 on one computer.
10

This is a better way:

ffmpeg -re -i udp://10.1.1.238:1234?fifo_size=1000000 -vcodec libx264 -vb 500000 -g 60 -vprofile main -acodec aac -ab 128000 -ar 48000 -ac 2 -vbsf h264_mp4toannexb -b 1000k -minrate 1000k -maxrate 1000k -strict experimental -f stream_segment -segment_format mpegts -segment_time 5 -segment_atclocktime 1 -reset_timestamps 1 -strftime 1 d:/%H%M%S.mp4

By this code ffmpeg makes series of output files using current system time.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.