FFMPEG H264 split demux a stream video
You can use -map
to select your desired streams, and -codec copy
(or the -c copy
alias) to use stream copy mode instead of re-encoding:
ffmpeg -i input \
-map 0:v:0 -codec copy output0 \
-map 0:v:1 -codec copy output1 \
-map 0:v:2 -codec copy output2 \
-map 0:v:3 -codec copy output3
0:v:3
refers to: select first input (0
), select video stream type (v
), select the fourth video stream (3
). Note that ffmpeg
starts counting from 0 for -map
, so that is why 3
is the fourth stream.
The above example, in your case, is the same as:
ffmpeg -i input \
-map 0:1 -codec copy output0 \
-map 0:2 -codec copy output1 \
-map 0:3 -codec copy output2 \
-map 0:4 -codec copy output3
...but I generally find the first method more flexible.
Related videos on Youtube
Luke
Updated on September 18, 2022Comments
-
Luke over 1 year
I've got an H264 video (Stored in an 264 file). With ffplay i see that:
[NULL @ 00000000003454a0] start time for stream 0 is not set in estimate_timings _from_pts [mpeg @ 0000000000344560] Could not find codec parameters for stream 0 (Audio: mp2, 0 channels): unspecified frame size Consider increasing the value for the 'analyzeduration' and 'probesize' options Input #0, mpeg, from 'int_max.264': Duration: 03:37:45.30, start: 35437.583167, bitrate: 6574 kb/s Stream #0:0[0x1c0]: Audio: mp2, 0 channels Stream #0:1[0x1e1]: Video: h264 (Constrained Baseline), yuv420p, 704x576, 25 tbr, 90k tbn Stream #0:2[0x1e2]: Video: h264 (Constrained Baseline), yuv420p, 704x576, 25 tbr, 90k tbn Stream #0:3[0x1e0]: Video: h264 (Constrained Baseline), yuv420p, 704x576, 25 tbr, 90k tbn Stream #0:4[0x1e3]: Video: h264 (Constrained Baseline), yuv420p, 704x576, 25 tbr, 90k tbn
Is it possible to split this file in four single files h264,one file for any stream ?? Can I do this with ffmpeg? How is this possible? Can I give me some advice?
I've got FFmpeg and x264 available. I'm happy to use either the FFmpeg command line, or my own program linked against ffmpeg of x264 libraries.