PDA

View Full Version : [ubuntu] Demux an mp4


azangru
January 31st, 2009, 01:50 PM
Okay, so here is an mp4 file that contains a video stream in H264 format and an audio stream in AAC format. Is there an easy linux way to extract these two streams and reencode them individualy into something less exotic? Like get an .m2v video file and a .wav audio file?

sleepingdragon
February 1st, 2009, 09:17 AM
Avidemux allows you to separate audio and video and convert them into different formats. To do the audio, select your audio type from the drop-down list on the left, configure to your exact needs and then use the Audio -> Save menu item.

The video can be done by changing the main audio track to "none" then selecting the appropriate video codec for your needs - then you save it. You'll then have the two separate streams you asked for.

FakeOutdoorsman
February 1st, 2009, 02:36 PM
FFmpeg can do this as well. For the audio:
ffmpeg -i input.mp4 output.wav
And now the video:
ffmpeg -i input.mp4 -sameq output.m2v
You will need the libavcodec-unstripped-51 package in addition to ffmpeg to activate restricted encoders such as mpeg2video, libfaac, libmp3lame, mpeg4, etc.

azangru
February 2nd, 2009, 03:18 PM
Thank you very much for the advice! The ffmpeg way turned out to be even easier than avidemux, because I got all confused choosing the right video codec in the left-hand panel.

The weird thing with ffmpeg, though, is that the frame size of the saved video track became a bit smaller than the original, so the peripheral part of the image was cut off. Is there any way I could tune the frame size?

FakeOutdoorsman
February 2nd, 2009, 04:07 PM
The weird thing with ffmpeg, though, is that the frame size of the saved video track became a bit smaller than the original, so the peripheral part of the image was cut off. Is there any way I could tune the frame size?
That's odd because it shouldn't change the frame size unless you tell it to. Paste your FFmpeg command and the full output. You can specify frame size with the -s option: -s 640x480 for example.

azangru
February 2nd, 2009, 05:42 PM
Ok, I re-checked and it turned out I was wrong. The frame size in the m2v output is correct; the cutting of the frame occurs when I import the m2v file in Adobe Premiere on another computer.

FakeOutdoorsman
February 3rd, 2009, 12:42 AM
Ok, I re-checked and it turned out I was wrong. The frame size in the m2v output is correct; the cutting of the frame occurs when I import the m2v file in Adobe Premiere on another computer.
Perhaps Premiere is choosing the incorrect aspect ratio. In Premiere, right click on a video file, choose Interpret Footage -> Conform to: and choose your aspect ratio.

azangru
February 3rd, 2009, 07:02 PM
I imported another version of the video file in Premiere, and now the frame size remained normal. The difference from the previous version was that this time it was not high-definition. Perhaps, Premiere was having problems with high def. :-? That's all right, though; I didn't really need high definition.

Thank you very much for the help!