Changes between Version 4 and Version 5 of Encode/AAC


Ignore:
Timestamp:
Jan 12, 2013, 8:10:07 AM (6 years ago)
Author:
llogan
Comment:

"-afterburner 1" is default; -vbr probably doesn't need a stream specifier

Legend:

Unmodified
Added
Removed
Modified
  • Encode/AAC

    v4 v5  
    33[[PageOutline(2-3, Contents)]] 
    44 
    5 [[http://en.wikipedia.org/wiki/Advanced_Audio_Coding|AAC, Advanced Audio Coding]], is the successor format to MP3, and is defined in MPEG-4 part 3. It is often used within an MP4 container format, for music the .m4a extension is customarily used. The second-most common use is within MKV (Matroska) files because it has better support for embedded text-based soft subtitles than MP4. The examples in this guide will use the extensions MP4 and M4A. 
     5[[http://en.wikipedia.org/wiki/Advanced_Audio_Coding|Advanced Audio Coding (AAC)]], is the successor format to MP3, and is defined in MPEG-4 part 3. It is often used within an MP4 container format, for music the .m4a extension is customarily used. The second-most common use is within MKV (Matroska) files because it has better support for embedded text-based soft subtitles than MP4. The examples in this guide will use the extensions MP4 and M4A. 
    66 
    77FFmpeg can support four AAC-LC encoders (`aac`, `libfaac`, `libfdk_aac`, `libvo_aacenc`) and two AAC-HC encoders (`libaacplus` and `libfdk_aac`). `libaacplus`, `libfaac`, and `libfdk_aac` are considered "non-free", and are therefore non-redistributable meaning you may have trouble finding a build that supports these. Of course you can resolve this by [[CompilationGuide|compiling ffmpeg]]. 
     
    1111== libfdk_aac ==#fdk_aac 
    1212 
    13 This is currently the highest-quality AAC encoder available with ffmpeg. Requires ffmpeg to be configured with `--enable-libfdk_aac`. 
    14  
    15 `-afterburner 1` enables 'high-quality' mode. It doesn't add any noticeable length to the encoding time, or increase the filesize; so unless you have a specific reason not to, you should use it. 
     13Fraunhofer FDK AAC codec library. This is currently the highest-quality AAC encoder available with ffmpeg. Requires ffmpeg to be configured with `--enable-libfdk_aac --enable-nonfree`. 
    1614 
    1715=== Variable Bit Rate (VBR) mode ===#fdk_vbr 
    1816 
    19 These settings target a ''quality'', rather than a specific ''bit rate''. 1 is lowest quality (though still pretty good) and 5 is highest quality. For some people with some files, even a VBR of 1 is indistinguishable from CD-quality audio; test it out and use the lowest setting that works for you. This mode is not compatible with [[#fdk_he|AAC-HE]], but for AAC-LC (the default for ffmpeg, and most compatible [[http://en.wikipedia.org/wiki/Advanced_Audio_Coding#Modular_encoding|AAC profile]]) it should probably be preferred, since it allows the encoder greater flexibility to distribute bits as it sees fit: high-tempo, large dynamic range audio (like dubstep or rock music) requires more bits to encode then low-tempo, low dynamic range audio (like whalesong, or a recorded lecture - though there are special speech codecs that you should consider for the latter). Set the VBR level with the `-vbr:a` flag. 
     17These settings target a ''quality'', rather than a specific ''bit rate''. 1 is lowest quality (though still pretty good) and 5 is highest quality. For some people with some files claim even a VBR of 1 is indistinguishable from CD-quality audio; test it out and use the lowest setting that works for you. This mode is not compatible with [[#fdk_he|AAC-HE]], but for AAC-LC (the default for ffmpeg, and most compatible [[http://en.wikipedia.org/wiki/Advanced_Audio_Coding#Modular_encoding|AAC profile]]) it should probably be preferred, since it allows the encoder greater flexibility to distribute bits as it sees fit: high-tempo, large dynamic range audio (like dubstep or rock music) requires more bits to encode then low-tempo, low dynamic range audio (like whalesong, or a recorded lecture - though there are special speech codecs that you should consider for the latter). Set the VBR level with the `-vbr` flag. 
    2018 
    2119According to [[http://www.hydrogenaudio.org/forums/index.php?showtopic=95989|this hydrogenaudio post]], the VBR modes (on average, over a number of files) give the following bit rates per channel (so for stereo, double the bit rate; for 5.1 surround sound, multiply it by six): 
     
    3331 
    3432{{{ 
    35 ffmpeg -i input.wav -c:a libfdk_aac -vbr:a 3 -afterburner:a 1 output.m4a 
     33ffmpeg -i input.wav -c:a libfdk_aac -vbr 3 output.m4a 
    3634}}} 
    3735 
     
    3937 
    4038{{{ 
    41 ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -vbr:a 3 -afterburner:a 1 output.mp4 
     39ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -vbr 3 output.mp4 
    4240}}} 
    4341 
     
    4644{{{ 
    4745ffmpeg -i input.mp4 -c:v libx264 -crf:v 22 -preset:v veryfast \ 
    48 -ac 2 -c:a libfdk_aac -vbr:a 3 -afterburner:a 1 output.mp4 
     46-ac 2 -c:a libfdk_aac -vbr 3 output.mp4 
    4947}}} 
    5048 
     
    5856 
    5957{{{ 
    60 ffmpeg -i input.wav -c:a libfdk_aac -b:a 128k -afterburner:a 1 output.m4a 
     58ffmpeg -i input.wav -c:a libfdk_aac -b:a 128k output.m4a 
    6159}}} 
    6260 
     
    6462 
    6563{{{ 
    66 ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -b:a 384k -afterburner:a 1 output.mp4 
     64ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -b:a 384k output.mp4 
    6765}}} 
    6866 
     
    7270ffmpeg -y -i input.mp4 -c:v libx264 -b:v 933k -preset:v veryfast -pass 1 -an /dev/null && \ 
    7371ffmpeg -i input.mp4 -c:v libx264 -b:v 933k -preset:v veryfast -pass 2 \ 
    74 -ac 2 -c:a libfdk_aac -b:a 128k -afterburner:a 1 output.mp4 
     72-ac 2 -c:a libfdk_aac -b:a 128k output.mp4 
    7573}}} 
    7674 
     
    8179Unfortunately, many devices that can play AAC-LC (the default profile for fdk_aac) simply cannot play either version of AAC-HE, so this is not recommended for surround sound audio, which normally needs to be compatible with such hardware players. If you are only going to play it on your computer, or you are sure that your hardware player supports AAC-HE, you can aim for a bit rate of 160kb/s for version 1, or 128kb/s for version 2. As always, experiment to see what works for your ears. 
    8280 
    83 The following examples are taken from [[http://ubuntuforums.org/showpost.php?p=12421935&postcount=34|this ubuntuforums post]]. 
     81The following examples are adapted from [[http://ubuntuforums.org/showpost.php?p=12421935&postcount=34|this ubuntuforums post]]. 
    8482 
    8583==== AAC-HE version 1 ==== 
    8684 
    8785{{{ 
    88 ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k -afterburner:a 1 output.m4a 
     86ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k output.m4a 
    8987}}} 
    9088 
     
    9290 
    9391{{{ 
    94 ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k -afterburner:a 1 output.m4a 
     92ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k output.m4a 
    9593}}} 
    9694 
     
    111109== libvo_aacenc == 
    112110 
    113 !VisualOn AAC encoding library. Requires ffmpeg configuration with `--enable-libvo-aacenc`. This has the advantage of not being non-free, and is included by some distributors, but is a rather poor encoder compared to libfdk_aac and even the native FFmpeg AAC encoder according to [http://d.hatena.ne.jp/kamedo2/20120729/1343545890 Quality Assessment of FFmpeg AAC]. 
     111!VisualOn AAC encoding library. Requires ffmpeg configuration with `--enable-libvo-aacenc`. This has the advantage of not being non-free, and is included by some distributors, but is a rather poor encoder compared to libfdk_aac and even the native FFmpeg AAC encoder according to [http://d.hatena.ne.jp/kamedo2/20120729/1343545890 Quality Assessment of FFmpeg AAC]. This encoder does not work with `-q:a`/`-qscale:a`. 
    114112 
    115113==== Example ====