Can FFMPEG record from webcam in (for instance 10 sec.) intervals ? I need contiguous small videos from webcam (used for a p2p live streaming app, which I'm developing), so that I can play them one after the after without noticing, that there are actually multiple videos.
I guess, I have to break on key-frames or something like this, so that I have clear cuts.
For playing multiple videos without stuttering I use the Web MediaSource API and it does actually work quite well already.
I only need to segment a webcam stream into multiple variable video files.
Thanks!
You can use the general purpose stream segmenter or the specific Apple HTTP Live Streaming (HLS) segmenter.
Example for the stream segmenter on Linux:
ffmpeg -f v4l2 -framerate 25 -video_size 640x480 -i /dev/video0 -an -f segment -segment_time 10 -segment_format_options movflags=+faststart out%03d.mp4
You can set a constant keyframe interval with the GOP size option (-g
), ie:
-c:v libx264 -r 25 -g 50
puts a keyframe every 2s (50 frames at 25 fps). The segment duration must be a multiple of the keyframe interval.