Ubuntu – How to convert AC3 6ch audio to HE-AAC? GUI solution

aaccodecsencoding

I want to convert the audio track of a MKV file to HE-AAC (AAC+/AACplus). The audio track is AC3. But there seems no GUI for HE-AAC encoding? I only found out there is a Command Line Tool (CLI) from Nero, but I don't know if this can do HE-AAC.

Any help? Any recommendation for a GUI that can convert AC3 to HE-AAC? Also should be able to handle surround sound (5.1/6-channels).

Best Answer

Nero AAC Encoder usage

neroAacEnc does support HE-AAC and HE-AAC v2 via -he and -hev2 parameters.

This encoder is (still?) considered to be the best encoder quality wise. Nero offers it free of charge but doesn't give support for it. One problem you will encounter with large files like 5.1 WAV is the file size limitation. It is not due to this encoder being crippleware, but how to handle large numbers in a program. To workaround this you need to pipe the input with another program to the encoder and use the -ignorelength parameter. If you input format is already WAV the following should work:

cat $myfile | neroAacEnc -q 0.5 -he -ignorelength -if - -of $myencodedfile

You can also use avconv (formerly known as ffmpeg, now forked and with the CLI tool being renamed) to do the conversion to WAV.

avconv -i $myfile -f wav - | neroAacEnc -q 0.3 -he -ignorelength -if - -of $myencodedfile

Note that the resulting file is a MP4 with a AAC stream in a MP4 container, not a raw AAC stream. You can extract the raw stream with MP4Box from the gpac package if you want to.

Nero AAC quality setting

The quality setting depends on the profile you use. With LC-AAC you can go up to -q 1.0. HE-ACC is limited to -q 0.5, I think, and HE-AAC v2 even lower. This is due the techniques behind those profiles that are centered around low bitrates. Using -q 0.5 will result in a file larger than common AC3 6ch audio from a DVD, using -q 0.3 will cut the file size in half.

Advice for codec and quality choice on multichannel audio

The situation is (still?) really messy, which is why there exist no easy to use GUI like Handbrake. The most efficient codec is HE-AAC v2 but it is not well supported in Ubuntu, due to licensing/patent issues in some countries. Vorbis is good too, but less efficient. Multichannel mapping should be fixed in the latest LTS release (12.04, it wasn't in 10.04). Leaving out MP3, AC3 comes in third place. FLAC is 4th on efficiency and the most supported lossless format. DTS is a complete looser and should be also left out, like MP3. Convert to FLAC if you can.

So if you have AC3 encoded audio, you probably leave it at that if the device and container format supports it. The chart for supported media formats on Android might be helpful.

Appendix: neroAacEnc help file

Usage:
neroAacEnc [options] -if <input-file> -of <output-file>
Where:
<input-file>  : Path to source file to encode.
                The file must be in Microsoft WAV format and contain PCM data.
                Specify - to encode from stdin.
                Note that multiple input files can be specified, they will be
                encoded together into a single output file with chapter marks
                indicating source file divisions.
<output-file> : Path to output file to encode to, in MP4 format.

  ==== Available options: ====  

Quality/bitrate control:
-q <number>   : Enables "target quality" mode.
                <number> is a floating-point number in 0...1 range.
-br <number>  : Specifies "target bitrate" mode.
                <number> is target bitrate in bits per second.
-cbr <number> : Specifies "target bitrate (streaming)" mode.
                <number> is target bitrate in bits per second.
                When neither of above quality/bitrate options is used,
                the encoder defaults to equivalent of -q 0.5

Multipass encoding:
-2pass        : Enables two-pass encoding mode.
                Note that two-pass more requires a physical file as input,
                rather than stdin.
-2passperiod  : Overrides two-pass encoding bitrate averaging period, 
  <number>    : in milliseconds.
              : Specify zero to use least restrictive value possible (default).

Advanced features / troubleshooting:
-lc           : Forces use of LC AAC profile (HE features disabled).
-he           : Forces use of HE AAC profile (HEv2 features disabled).
-hev2         : Forces use of HEv2 AAC profile
                Note that the above switches (-lc, -he, -hev2) should not be
                used; optimal AAC profile is automatically determined from
                quality/bitrate settings when no override is specified.
-ignorelength : Ignores length signaled by WAV headers of input file.
                Useful for certain frontends using stdin.