By Werner Ruotsalainen updated on 10/08/2012
UPDATE (06/Oct/2012): I've posted an entirely new section to the second half of the article on MKV audio editing. Please scroll down to today's update.
In my previous article on iOS developers being forced to drop AC-3 support from their players, I've explained you either keep the old versions of your media players or won't be able to listen to the audio track of AC-3-only video files (MP4's, MKV's etc.). In this tutorial, I explain an alternative for people that don't want to do all the hassles of manually backing up and restoring IPA files (one of the ways of playing those files back) or just want to use the most up-to-date versions of multimedia players in the future too.
Note that this tutorial is not only meant for folks that have video files with AC-3 audio only. It's a more generic article showing you how you can use the best OS X apps to add new audio tracks to a video file so that it has multiple audio tracks.
In the article, I only discuss MP4's (basically, the same as M4V's and MOV's) and MKV's, the two most popular multimedia file (“container”) formats of today when it comes to non-native camera videos or broadcast formats (this means I don't discuss (M)TS files as they aren't used in non-broadcast movie distribution / ripping). Just a quick recap on the two formats:
1, MKV's are the containers representing the freedom of putting any kind of multimedia content (even the obscurest video, audio, subtitle font, subtitle etc. formats, textual messages for humans etc.) in the same file. It's hardware playback-wise, widely supported on the more open mobile operating systems (Symbian Anna / Belle, Android) and is the native output format of immensely useful DVD / Blu-ray / HD DVD ripper tools like MakeMKV. The latter simply couldn't create MP4's (see next paragraph) out of optical discs because MP4's just can't hold some kinds of data types; for example, Blu-ray subtitles (S_HDMV/PGS).
2, MP4's (M4V's and MOV's) are of extremely high importance to iOS and Apple TV users because it's the only format that these devices can play without third-party apps or without jailbreaking, respectively. And even if you do use third-party apps on iDevices, other container formats can only be played back utilizing the vastly superior hardware acceleration only using certain tricks like behind-the-scene remuxing (dedicated article) – Apple has forbidden the direct hardware decoding of non-native (MP4) files.
MP4's, unfortunately, are really inferior to MKV's in that they can't hold even common video / audio (for example, Vorbis) formats, let alone the above-mentioned native Blu-ray subtitles (PGS). No wonder it's MKV's that MakeMKV rips your discs to and not MP4's.
Now, let's see how you can add an AAC audio track to both MKV and MP4 files originally only containing an AC-3 (Dolby Digital) audio track. Should you want to follow the tutorial, feel free to download THIS (MKV) or THIS (MP4).
For the time being, let's start with MP4's as, for some reason, MKVTools (neither the official nor the latest beta version) doesn't seem to behave as it should – it just doesn't convert the test AC-3 audio to AAC on my Mountain Lion MBP. I will definitely return to the question and add an MKV-related section as soon as I find out why it's doing so and update the article. Hopefully I don't end up having to recommend more than one tool for MKV editing. (It's certainly possible – the workflow is just not sufficiently simple without using in-built AAC conversion in MKVTools.)
Get Subler (download HERE; you'll want to choose the latest non-CLI version). Start it.
1, Cmd + O: open the MP4 file:
2, click the + button (annotated in the above screenshot) and select the same(!) MP4 file. You'll be presented a previously not shown, new dialog:
Here, I've annotated a checkbox in the top left corner, in the “Video Track” (see the third, “Name” column) row. You must deselect it to avoid the video track included in the same target MP4 file twice. You must also check whether the “Action” column in the “Sound Track” row reads something starting with “AAC”. If it reads “Passthru” (as does the video track in the above screenshot), you'll need to change it to, say, AAC – Dolby Pro Logic II. (If you do plan to add AAC tracks to several files, to avoid having to set this one-by-one, make sure you enable the “Convert: AC3 audio to AAC” checkbox under Preferences > Audio. The enabled state of this checkbox makes this default action to “convert”. Of course, as with the non-selected case, you can always override the action to be taken.)
After all this, you'll see the following in the main window:
Note the third row, starting with “na” showing it's still not saved and, therefore, doesn't have a tangible ID in the target file. Don't pay attention to the last, “Format” column (still) showing “AC-3, 6ch” - Subler does know it'll need to convert this audio track to AAC upon saving.
3, Now, press Cmd + S (of course, you can also select Save As not to overwrite the original file) and the file will be saved; now, with two audio tracks. After finishing the saving, the main dialog will also change:
Can you spot the difference with the previous screenshot? If you understand the content of the paragraph starting with “Note the third row, starting with “na” showing” just above, you'll immediately know why there's a “3” instead of the “na” in the first column: this track ID now comes from a real file and not just one that will be created only later. The same stands for the “Format” column: instead of “AC-3, 6ch”, it already reads “AAC, 2 ch”, showing this particular track is indeed in AAC.
This file can already be played back by both via hardware decoding and from software. (Of course, with the current – rather meagre – processing power of iDevices, you won't want to use the latter with a 1080p movie like this example. Also note that, should you want to synch the video directly to the stock Videos app via iTunes, you'll also need to change its H.264 level by highlighting the Video Track and setting the lowermost “H.264 Video Profile / Level” to High @ 4.1 from the default 5.1 as can be seen in THIS screenshot of the same two-audio track file. (The drop-down menu and the optimal value is annotated.))
Also note that Subler can't directly save MKV files; however, it can remux (change the container of) an MKV to an MP4 file. (Actually, this is why Subler is by far the most recommended remuxer utility for OS X.)
UPDATE (06/Oct/2012): as promised in the original article, I've played further with MKVTools and have managed to come up with a sufficiently straightforward workflow not involving other apps. It's not as simple as should be because of the lack of automatic AAC audio track addition, despite the “add 2-Ch. Track” checkbox stating it would downmix audio to AAC, though. (This may be a bug in the program as of version 3.2b4 (1)?)
Get the latest beta(!!) version of MKVTools (don't bother with the non-beta version of the app or its bother, MP4Tools – in addition to being far slower and less reliable, version 3.0 of MKVTools doesn't even have the “add 2-Ch. Track” checkbox we'll need) from http://www.emmgunn.com/betadownload.html. Start it, click “Open” in the upper right corner and select the MKV video to import:
Enable all checkboxes on the left; a shortcut of this is just clicking the v(ideo) / a(udio) / s(ubtitle) buttons directly beneath it (as with the track checkboxes, annotated below).
After enabling audio, the “Audio” radio button + checkbox section in the lower center becomes active. Enable the “add 2-Ch. Track” checkbox there (annotated below). The following screenshot also shows the help the app displays when hovering the cursor over this checkbox:
Make sure you check it in. After this, just click “Convert” in the bottom right corner.
The MKV file MKVTools now generates (named <original filename>.mkv.muxed.mkv), as opposed to what one would think, doesn't have the additional AAC audio track and can be just deleted, along with all the .log files in the same directory. However, in the same (target) directory, you'll also find a file “<original filename>.mkv.temp.Audio.t0.added.aac”. In the following screenshot, I show this case, along with the original file (“mkv-with-ac3.mkv”). The AAC file we'll need is named “mkv-with-ac3.mkv.temp.Audio.t0.added.aac” and is annotated in the screenshot:
Now, click the “Add track” button annotated in the next screenshot:
(Note that I've kept the result pane in the screenshot telling the MKV conversion, which we needed to extract the AAC temporary file, was successful.)
and select the AAC audio track just created:
You'll see the following:
You absolutely must enable the checkbox in the first column of the just-added audio track – this is the leftmost annotation above. In addition, you may want to give your audio tracks meaningful names (above, they both have the name "Audio Track"); for example, AC-3 for the AC-3 one and AAC to the other (just click the fields to edit them). Finally, you may also want to change the language flag of the track from “undetermined” to something else; e.g., English. The following screenshot shows all this:
Now, just click “Convert” in the bottom right corner. You don't need to touch the audio settings before doing so – you can keep them intact.
Side note: Unfortunately, the AAC extraction explained in the first half of this update is probably the easiest way of extracting an automatically (AC-3 -> AAC) downmixed audio track out of an MKV.
1, If you extract an audio track from MKVTools itself (in the second, “Edit Tracks” tab), then, regardless of whether you've instructed it to do AAC downmixing in the first (“MKV”) tab, it'll create an AC-3 file.
2, Subler only supports exporting non-video/audio tracks (that is, for example, subtitles) from an MKV via File > Export and can't save an audio-only file to a true AAC file either: the only output audio format it supports, “Audiobook-MPEG4”, is not meant for such kind of audio extracting.
3, the otherwise excellent avidemux 2.6 doesn't support converting + exporting to purely audio files (AAC in this case), only to combined (audio + video) or strictly video files.
4, Finally, neither can Mkvtoolnix (which we used for VobSub-import HERE) export to true AAC files – only to MKA (the audio-only equivalent of MKV's) and that without AC-3 -> AAC downmixing.
UPDATE (08/Oct/2012): as an addition to the list at the bottom,
5, QuickTime 7 Pro (see today's update HERE for more info on acquiring it and some tips on using it to check out individual interlaced fields) can't export any kind of compressed audio – including AAC or AC3. Here's the output formats you can select under File > Export..., in the “Export” drop-down list at the bottom: