Changes between Version 4 and Version 5 of AACEncodingGuide
- Timestamp:
- 01/12/2013 07:10:07 AM (4 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
AACEncodingGuide
v4 v5 3 3 [[PageOutline(2-3, Contents)]] 4 4 5 [[http://en.wikipedia.org/wiki/Advanced_Audio_Coding|A AC, 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. 6 6 7 7 FFmpeg 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]]. … … 11 11 == libfdk_aac ==#fdk_aac 12 12 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. 13 Fraunhofer 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`. 16 14 17 15 === Variable Bit Rate (VBR) mode ===#fdk_vbr 18 16 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.17 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 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. 20 18 21 19 According 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): … … 33 31 34 32 {{{ 35 ffmpeg -i input.wav -c:a libfdk_aac -vbr :a 3 -afterburner:a 1output.m4a33 ffmpeg -i input.wav -c:a libfdk_aac -vbr 3 output.m4a 36 34 }}} 37 35 … … 39 37 40 38 {{{ 41 ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -vbr :a 3 -afterburner:a 1output.mp439 ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -vbr 3 output.mp4 42 40 }}} 43 41 … … 46 44 {{{ 47 45 ffmpeg -i input.mp4 -c:v libx264 -crf:v 22 -preset:v veryfast \ 48 -ac 2 -c:a libfdk_aac -vbr :a 3 -afterburner:a 1output.mp446 -ac 2 -c:a libfdk_aac -vbr 3 output.mp4 49 47 }}} 50 48 … … 58 56 59 57 {{{ 60 ffmpeg -i input.wav -c:a libfdk_aac -b:a 128k -afterburner:a 1output.m4a58 ffmpeg -i input.wav -c:a libfdk_aac -b:a 128k output.m4a 61 59 }}} 62 60 … … 64 62 65 63 {{{ 66 ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -b:a 384k -afterburner:a 1output.mp464 ffmpeg -i input.mp4 -c:v copy -c:a libfdk_aac -b:a 384k output.mp4 67 65 }}} 68 66 … … 72 70 ffmpeg -y -i input.mp4 -c:v libx264 -b:v 933k -preset:v veryfast -pass 1 -an /dev/null && \ 73 71 ffmpeg -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 1output.mp472 -ac 2 -c:a libfdk_aac -b:a 128k output.mp4 75 73 }}} 76 74 … … 81 79 Unfortunately, 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. 82 80 83 The following examples are takenfrom [[http://ubuntuforums.org/showpost.php?p=12421935&postcount=34|this ubuntuforums post]].81 The following examples are adapted from [[http://ubuntuforums.org/showpost.php?p=12421935&postcount=34|this ubuntuforums post]]. 84 82 85 83 ==== AAC-HE version 1 ==== 86 84 87 85 {{{ 88 ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k -afterburner:a 1output.m4a86 ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he -b:a 64k output.m4a 89 87 }}} 90 88 … … 92 90 93 91 {{{ 94 ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k -afterburner:a 1output.m4a92 ffmpeg -i input.wav -c:a libfdk_aac -profile:a aac_he_v2 -b:a 32k output.m4a 95 93 }}} 96 94 … … 111 109 == libvo_aacenc == 112 110 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`. 114 112 115 113 ==== Example ====


