Adding two audio tracks to an mp4 file

Started by rickyh, July 16, 2012, 04:22:33 PM

Previous topic - Next topic

rickyh

I have been running experiments to see if I can create good mp4 files of movies I already have on DVD so that they can be kept in iTunes and be accessible to (or streamed to) my Apple TV.

I have discovered that iTunes and Apple TV require a stereo audio track otherwise they both choke on the file.  I have therefore used Avidemux to convert to H.264 and downmix an AAC stereo track from one of the AC3 6 channel audio tracks in the VOBs.

I wanted though to keep the 5.1 information so that when in future I buy a surround sound receiver, I can select the surround track in iTunes and use the HDMI output from the Apple TV as an input to the receiver.

I have discovered that (as is recorded elsewhere on this forum) Avidemux cannot yet create an mp4 file with two audio tracks in it.  An avi dual audio file is no good for use with iTunes or Apple TV.  So, specifically I want to do this:

Track 0:  H.264 Video
Track 1:  AAC 128kbps (or better downmixed from DTS 6 channel) Stereo
Track 2:  Original DTS 768kbit/s 6 channel audio (or AC3 384kbit/s where quality not important)

....all in an mp4 wrapper.

I have now succeeded in achieving this goal by extracting the 6 channel audio into a separate file as per the Avidemux documentation, and then transcoding the movie to H.264 with an AAC stereo downmixed 'Main' audio track.

To bypass the current limitations of Avidemux in respect of multi-channel mp4 creation I used ffmpeg to add the second 6 channel AC3 audio track back into the Avidemux transcoded mp4 file as follows (I post this in case it helps anyone else):

ffmpeg.exe -i inputfile.mp4 -i additionalaudiotrack.ac3 -map 0:v -codec:v copy -map 0:a:0 -codec:a copy -map 1:a:0 -codec:a copy output.mp4

Please can someone tell me if there are plans to enhance Avidemux to enable this to be done without having to resort to using other transcoding tools.

Many thanks
Richard

Jan Gruuthuse

#1
avidemux 2.6 can handle up to 4 audiotracks: copy, switching positions like track 2 to 0 and 0 to 2, adding, transcoding. If the container allows this, then it probably should work. I can only confirm this for MPEG-TS streams and container (SD & HD) and MKV. Have not tested this with .mp4 container.

styrol

QuoteI have been running experiments to see if I can create good mp4 files of movies I already have on DVD so that they can be kept in iTunes and be accessible to (or streamed to) my Apple TV.

You might try Handbrake for this kind of task. It's focused on MP4 and MKV and h.264 and MPEG-4 Part 2 respectively.

binky

Quote from: rickyh on July 16, 2012, 04:22:33 PM
(I post this in case it helps anyone else):

ffmpeg.exe -i inputfile.mp4 -i additionalaudiotrack.ac3 -map 0:v -codec:v copy -map 0:a:0 -codec:a copy -map 1:a:0 -codec:a copy output.mp4

Many thanks Richard - it works like a charm.  I've converted my Bluray discs using DVDFab to PS Vita MP4 files as they seem to be the most compatible for Android, AppleTV, iPhone, iPad, PC, Mac and then extracted the AC3 audio using "FLV MP3 Converter" and using the ffmpeg example you provided, I've added back in the AC3 as a second audio track... Perfect  8)

Binky

styrol

QuoteI have discovered that iTunes and Apple TV require a stereo audio track otherwise they both choke on the file.
AC3 5.1 is supported in M4V container (the iTunes MP4 container providing some extensions). If there is a second track (e.g. AAC Stereo), iTunes always play this track (not the 5.1 one). The 5.1 track is there, but you cannot select it in iTunes cause it's grayed out).

Quotethen extracted the AC3 audio using "FLV MP3 Converter" and using the ffmpeg example you provided, I've added back in the AC3 as a second audio track...
Hm, rather complicated. In Handbrake just select M4V as default MP4 extension (important), select x.264 as video codec and use AC3 passthrough. ITunes will be playing the 5.1 audio track. Sample (14MB): M4V (H.264 video / AC3 5.1 audio) from VOB source.