I have some m4v files I made with Handbrake where the AC3 audio channel was the first one, and the stereo was the second. This causes problems with some things (like Quicktime) so I want to repackage the file such that the stereo track is the first audio track. I don't want to re-encode things.

Can I do this? Can I do it for free?

link|improve this question

76% accept rate
feedback

1 Answer

up vote 2 down vote accepted

Get MP4BOX and do it in a couple of passes.

First, get a good look at the streams in file, you will need to know their numbers so you can extract them appropriately:

mp4box -info media_file.m4v

Next, you will want to extract the individual streams:

mp4box -raw 1 media_file.m4v
mp4box -raw 2 media_file.m4v
etc...

Finally, you will want to reassemble the streams into a new container. Make special note that you may need to adjust the fps - MP4BOX defaults to 25fps. The info command from step 1 should include the relevant info

mp4box -add media_file.x264 -add media_file.aac -add media_file.ac3 -fps 23.976 new_output_container.m4v

For good measure, you may want to also take advantage of the new itags support to inject a bit of metadata into your m4v container:

mp4box -itags "name=Your Great Movie" new_output_container.m4v
link|improve this answer
Took a bit to get compiled on Snow Leopard but it does what I want. Thanks! – Daniel Huckstep Nov 22 '09 at 19:45
Actually I missed the framerate part...I can't seem to see it in the output of the -info part of things... – Daniel Huckstep Nov 22 '09 at 20:05
You can usually find the framerate listed in the details using VLC as well if mp4box doesn't want to show it for some reason. – Goyuix Nov 22 '09 at 21:16
VLC informed me it was 25. Thanks! – Daniel Huckstep Nov 23 '09 at 4:16
While this worked, the audio was out of sync, so I'll have to play more. – Daniel Huckstep Nov 23 '09 at 5:12
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.