Extracting elementary streams from a container file to different files
Hello, What is the command (or commands) to extract all the elementary streams from a container file ? For example, the following file contains one audio stream and one video stream. $ ffmpeg -v 9 -i VID-3A.avi FFmpeg version SVN-r16078 configuration: --cc=gcc-4 --disable-vhook --disable-network libavutil 49.12. 0 / 49.12. 0 libavcodec 52. 6. 1 / 52. 6. 1 libavformat 52.23. 1 / 52.23. 1 libavdevice 52. 1. 0 / 52. 1. 0 built on Dec 18 2008 16:38:40, gcc: 4.3.2 20080827 (alpha-testing) 1 Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/2733) -> 23.98 (12570329/524288) Input #0, avi, from 'VID-3A.avi': Duration: 00:00:46.10, start: 0.000000, bitrate: 946 kb/s Stream #0.0, 524288/12570329: Video: mpeg4, yuv420p, 720x400 [PAR 1:1 DAR 9:5], 911/21845, 23.98 tb(r) Stream #0.1, 1/16000: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s At least one output file must be specified How do I demux the MPEG-4 ASP elementary stream into one file, and the MPEG Audio Layer III elementary stream into another file ? Side issues : 1.) "stream 0 codec frame rate differs from container frame rate" Does AVI specify a frame rate ? What happens when the frame rates differ ? Do some players lose sync ? 2.) 23.98 frames per second ?!? Why not 24 ? 12570329/524288 seems close to 24/1.001 1.001 has something to do with analog NTSC doesn't it ? (524288 = 2^19) -- Regards.
Marc Mason wrote:
What is the command (or commands) to extract all the elementary streams from a container file ?
For example, the following file contains one audio stream and one video stream.
$ ffmpeg -v 9 -i VID-3A.avi FFmpeg version SVN-r16078 configuration: --cc=gcc-4 --disable-vhook --disable-network libavutil 49.12. 0 / 49.12. 0 libavcodec 52. 6. 1 / 52. 6. 1 libavformat 52.23. 1 / 52.23. 1 libavdevice 52. 1. 0 / 52. 1. 0 built on Dec 18 2008 16:38:40, gcc: 4.3.2 20080827 (alpha-testing) 1
Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/2733) -> 23.98 (12570329/524288) Input #0, avi, from 'VID-3A.avi': Duration: 00:00:46.10, start: 0.000000, bitrate: 946 kb/s Stream #0.0, 524288/12570329: Video: mpeg4, yuv420p, 720x400 [PAR 1:1 DAR 9:5], 911/21845, 23.98 tb(r) Stream #0.1, 1/16000: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s
How do I demux the MPEG-4 ASP elementary stream into one file, and the MPEG Audio Layer III elementary stream into another file ?
I didn't find how to extract elementary streams, but I did manage to replace an audio stream with a different one. $ ffmpeg -v 9 -i audio.mp2 -i foo.avi -vcodec copy -acodec copy res.avi [...] Input #0, mp3, from 'audio.mp2': Duration: 00:00:30.00, start: 0.000000, bitrate: 128 kb/s Stream #0.0, 1/90000: Audio: mp2, 48000 Hz, stereo, s16, 128 kb/s Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/2733) -> 23.98 (12570329/524288) Input #1, avi, from 'foo.avi': Duration: 00:00:46.10, start: 0.000000, bitrate: 946 kb/s Stream #1.0, 524288/12570329: Video: mpeg4, yuv420p, 720x400 [PAR 1:1 DAR 9:5], 911/21845, 23.98 tb(r) Stream #1.1, 1/16000: Audio: mp3, 48000 Hz, stereo, s16, 128 kb/s Output #0, avi, to 'res.avi': Stream #0.0, 1/90000: Video: mpeg4, yuv420p, 720x400 [PAR 1:1 DAR 9:5], 524288/12570329, q=2-31, 23.98 tb(c) Stream #0.1, 1/90000: Audio: 0x0000, 48000 Hz, stereo, s16, 128 kb/s Stream mapping: Stream #1.0 -> #0.0 Stream #0.0 -> #0.1 frame= 1105 fps= 0 q=-1.0 Lsize= 5076kB time=30.00 bitrate=1386.1kbits/s dup=0 drop=0 video:4542kB audio:469kB global headers:0kB muxing overhead 1.307954% Then the result is : $ ffmpeg -v 9 -i res.avi [...] Seems stream 0 codec frame rate differs from container frame rate: 23.98 (65535/2733) -> 23.98 (12570329/524288) Input #0, avi, from 'res.avi': Duration: 00:00:46.08, start: 0.000000, bitrate: 902 kb/s Stream #0.0, 524288/12570329: Video: mpeg4, yuv420p, 720x400 [PAR 1:1 DAR 9:5], 911/21845, 23.98 tb(r) Stream #0.1, 3/125: Audio: mp2, 48000 Hz, stereo, s16, 128 kb/s I suppose -map might be useful to replace streams inside containers ?
Side issues :
1.) "stream 0 codec frame rate differs from container frame rate" Does AVI specify a frame rate ? What happens when the frame rates differ ? Do some players lose sync ?
Any comments ?
2.) 23.98 frames per second ?!? Why not 24 ? 12570329/524288 seems close to 24/1.001 1.001 has something to do with analog NTSC doesn't it ? (524288 = 2^19)
Any comments ? -- Regards.
I'm new to ffmpeg but maybe this might help a bit? Using -an (audio no?) and -vn will pull out the streams. Here is something I do to remove and replace a sound file on an flv. I tried using -newaudio but it corrupted the sound file (maybe map would have helped me, but this works for me): ffmpeg -i input.flv -vn output_sound.wav (I do this to mux in a soundtrack with ecasound) ffmpeg -i input.flv -vcodec copy -an output_nosound.flv ffmpeg -i output_nosound.flv -i input_sndtrk.mp3 -vcodec copy -acodec copy output_final.flv -- View this message in context: http://www.nabble.com/Extracting-elementary-streams-from-a-container-file-to... Sent from the FFmpeg-users mailing list archive at Nabble.com.
participants (2)
-
colevlly@pacbell.net -
mpeg.blue@free.fr