View Full Version : Two audio tracks in mp4 for iTunes
Patrick_H
15th February 2008, 17:57
Hey,
Until now I encoded all my DVDs to mp4 (h.264) with MeGUI and it's no problem to play them in iTunes. However, if I encode a video with more than one audio track, iTunes plays them simultaneously.
If I create a movie with Quicktime and specify the track names and the alternative track, iTunes lets me choose between the tracks and does not play them simultaneously.
I am just wondering if there is anything I could change in the mp4 file, so that iTunes won't play the audio tracks simultaneously from the movies I already encoded?
Thanks!
cacepi
17th February 2008, 07:27
I am just wondering if there is anything I could change in the mp4 file, so that iTunes won't play the audio tracks simultaneously from the movies I already encoded?
First the good news; you can fix this.
Now the bad news; it's a little complicated, and you have a Mac to do it.
The problem is the mp4 muxer in MeGUI doesn't add an edts/elst atom to the mp4 file. This isn't really MeGUI's fault as these atoms are found only in QuickTime, but without them it's damn near impossible to remux a file for iTunes/QuickTime compatiblity.
I know of no free tool that lets you do this on the PC.
If you do have a Mac, you can use mkvToolnix+Perian to fool QuickTime into inserting an edit list atom for you, but it's a pretty involved process. If you want to know, just reply and I'll write up a guide.
Patrick_H
17th February 2008, 15:44
Thanks cacepi,
that's great! I am looking for almost 3 days now to find a solution, but havn't found anything yet.
I've got a Pc and a Mac and I already tried to do it with Quicktime, but somehow it won't export two audio tracks.
It would be great if you could write a small guide for me!
cacepi
17th February 2008, 20:22
It would be great if you could write a small guide for me!Well, it's a guide, but small it ain't. A short warning about this:
While this will provide support for audio track switching in QuickTime and iTunes, it will not fix track switching for Front Row. The file will play in Front Row, but you won't be able to switch tracks. Not a drawback, since you couldn't switch audio tracks with Front Row in the first place.
You'll need the follow things:
QuickTime Pro. The final mux has to be in QuickTime Player; command line tools like QTCoffe or qt_tools will not work for this.
MKVToolnix (http://www.bunkus.org/videotools/mkvtoolnix/macosx/MKVToolnix-2.zip).
Perian (http://perian.org/).
After you've installed Perian and MKVToolnix, do the following:
1) If you have QuickTime running, quit it.
2) start mkvmerge and click the "add" button to add a file.
3) In the "Tracks:" view, highlight the first audio track and set its correct output language; "chi (Chinese)" for Chinese, "eng (English)" for English, etc.
4) Check "Make default track". If you've encoded the audio as HE-AAC make sure you've checked the "AAC is SBR/HE-AAC/AAC+" box in the "Format specific options" view.
5) Highlight the video track and set its language to be the same as the first audio track.
6) Check "Make default track".
7) Highlight the second audio track and set its language.
8) Do not check "Make default track"!
9) Note the output filename; you'll need to remember this for later.
10) Click "Start muxing". A second window will pop up showing a progress bar as the file muxes. If you're successful, you'll see "mkvmerge finished with a return code of 0. Everything went fine." under the "Status and progress" view. If not, go back through Steps 2-9 and double check them.
11) Open System Preferences and click the Perian icon in "Other". If you see an "Install Perian" button click it, otherwise quit System Preferences.
12) Start QuickTime and open your muxed file (see Step 9). Make sure it plays correctly: you should be able to select the different audio tracks under View --> Languages. If the audio is garbled or messed up it's probably because you did/didn't check "AAC is SBR/HE-AAC/AAC+" back in Step 4 when you should have.
13) Open the Movie Properties window (command-j).
14) Highlight the "Software" annotation and click "Remove Software Annotations"
15) Close the Movie Properties window.
16) Go back to your movie window and rewind movie to the beginning (command-left arrow).
17) Select "File --> Save as" (shift-command-s).
18) Click "Save as self-contained movie" and finally the "Save" button.
19) There is no Step 19.
You're done! Now that wasn't so easy, now was it? :)
After you're done you can disable Perian if you wish, but it isn't necessary. I personally prefer avc1Decoder (http://www003.upp.so-net.ne.jp/mycometg3/) as it offers you more control over playback settings, but that's neither here nor there.
Enjoy!
Ritsuka
17th February 2008, 20:32
Those are a lot of steps…
One easier way is to open the mp4 in Dumpster, and set the alternate_group field of every audio track's tkhd atom to 1.
cacepi
18th February 2008, 01:32
One easier way is to open the mp4 in Dumpster, and set the alternate_group field of every audio track's tkhd atom to 1.
I don't like the Dumpster option because it doesn't account for how the original mp4 is set; if you hadn't specified language tracks beforehand then you'll see "Unspecified language" for the track names in iTunes/QuickTime.
Yes, you can do it in Dumpster too, but you have to know the language_id; who can remember all of them? English is 21956, Japanese is 10766, French is 6721... German? Haven't a clue.
To say nothing that using Dumpster will break track switching with QuickTime Player itself, and IMO that's an outright deal breaker. The matroska/Perian method has the added benefit of producing a file editable in Quicktime; you can use QTCoffee to process as you see fit or fire up MP4Box to undo changes.
Or just save the matroska file as a reference movie; that works too.
If all you're interested in is switching tracks and don't care about anything else, then Dumpster is faster. Uglier, but faster.
CruNcher
18th February 2008, 03:33
While this will provide support for audio track switching in QuickTime and iTunes, it will break track switching in other apps. If you use VLC or MPlayer as well you will not be able to change audio tracks in these new files. This does not fix track switching for Front Row, either. The file will play in Front Row, but you won't be able to switch tracks.
Now this is crazy and a huge Interoperability problem @ the same time. Im wondering who does it wrong, you would expect that Apple does it right as they defined the .Mp4 file format and Mp4box does it wrong hmm?
cacepi
18th February 2008, 04:28
Im wondering who does it wrong, you would expect that Apple does it right as they defined the .Mp4 file format and Mp4box does it wrong hmm?
Hey, don't blame me; blame QuickTime.
I don't know how to answer your question, as the above method returns a QuickTime .mov file, not an .mp4 file, and 100% interoperablity between .mov and .mp4 isn't possible in this case without resorting to the one-step-above-hex-editor that is Dumpster.
--Edit: it seems I spoke too soon. Turns out track switching will work with VLC on both the PC and Mac, but only with MPlayer on the PC. The Mac MPlayer gui doesn't support track switching.
Patrick_H
19th February 2008, 12:56
Thanks it worked with both methods!
And with Dumpster you can even keep the mp4 format!
Drachir
19th February 2008, 15:12
... , you would expect that Apple does it right as they defined the .Mp4 file format and Mp4box does it wrong hmm?
Some words:
Apple didn't define the MP4 file Format(ISO/IEC 14496-14).
Apple is using the QuickTime and iTunes file format at the moment. This file formats are related to the ISO Base Media File Format(ISO/IEC 144496-12)
If your strict, most files around nowadays, produced by open source tools are not conformance to ISO/IEC 14496-14 (MP4 File Format) There enough commercial application around, which also unable to create clean MP4 files.
To have a file conformance to ISO/IEC 14496-14, there have to be an Object Descriptor, which isn't the case with most files around. (only an Object Descriptor doesn't make it an correct MP4 file ;) )
MP4Box is able to create standard conformace MP4 files.
You can create standard conformace MP4 files with MP4MenuGUI http://forum.doom9.org/showthread.php?t=117574
You can find some information here:
http://www.chiariglione.org/mpeg/technologies/mp04-ff/index.htm
Take a look at the text about "ISO Base Media File Format" and "MP4 File Format" and notice the difference.
Different file formats based at ISO Base Media File have different ways to define which tracks have to be played at once. In the MP4 file format this is defined with the SceneDescription.
The main ftyp Box in a ISO Base Media File, tell the player how he should handle the file for correct presentation. Is the main ftyp is set to "mp41" or "mp42" the player should act according the MPEG-4 Systems Information(ObjectDescriptor,SceneDescription...).
If the main ftyp Box is set to "m4v " or "m4a " like with apple iTunes files there are other rules for a correct presentation.
bond
2nd March 2008, 14:40
The problem is the mp4 muxer in MeGUI doesn't add an edts/elst atom to the mp4 file. This isn't really MeGUI's fault as these atoms are found only in QuickTime, but without them it's damn near impossible to remux a file for iTunes/QuickTime compatiblity.
I know of no free tool that lets you do this on the PC.megui uses mp4box as mp4 muxer from the gpac project
you can also try to add a feature request on the tracker of the gpac project on sourceforge asking them to add the edts/elst atom to their mp4s (altough not required by the specs)
Drachir
2nd March 2008, 17:20
MP4Box only use an Edit List Box if the time-line of a track is modified, so if the time-line of a track is mapped 1:1, there should be no need for an Edit List Box(elst).
Also only changes at the beginning are supported by MP4Box,AFAIK.
You can create an file with elst box, if you create an file with delay.
MP4Box -add test.mp4#1 -add test.mp4#2:delay=700 out.mp4 )
If the file was before in sync, now in a player with support for the elst box, video and audio should be out of sync. But most player don't know and ignore this box.
vBulletin® v3.8.11, Copyright ©2000-2026, vBulletin Solutions Inc.