Use -f stream_segment
(or the alias -f ssegment
). From the documentation:
stream_segment
is a variant of the segment
muxer used to write to
streaming output formats, i.e. which do not require global headers,
and is recommended for outputting e.g. to MPEG transport stream
segments. ssegment
is a shorter alias for stream_segment
.
Example command:
ffmpeg -f alsa -thread_queue_size 1024 -i hw:0 -f video4linux2 -i /dev/video0 -c:a aac -ar 48k -t 0:10 -segment_time 00:00.04 -f stream_segment sample-%003d.aac -c:v h264 -force_key_frames "expr:gte(t,n_forced*0.04)" -pix_fmt yuv420p -s:v 640x480 -t 0:10 -r 25 -g 1 -segment_time 00:00.04 -f stream_segment frame-%003d.h264
However, your output durations are so short you may have trouble playing them, but that's a completely different topic.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…