| 17 | | Detailed information about the FDK AAC library (not FFmpeg specific) can be found at the [[http://wiki.hydrogenaud.io/index.php?title=Fraunhofer_FDK_AAC|Fraunhofer FDK AAC]] page in the HydrogenAudio Knowledgebase. |
| 18 | | |
| 19 | | === Constant Bit Rate (CBR) mode ===#fdk_cbr |
| 20 | | |
| 21 | | These settings target a specific bit rate, with less variation between samples. It gives you greater control over file size, and it is compatible with the HE-AAC profile. As a rule of thumb, for audible transparency, use 64kb/s for each channel (so 128kb/s for stereo, 384 kb/s for 5.1 surround sound). Set the bit rate with the `-b:a` flag. |
| 22 | | |
| 23 | | ==== Examples ==== |
| | 15 | Detailed information about the FDK AAC library (not FFmpeg specific) can be found at [http://wiki.hydrogenaud.io/index.php?title=Fraunhofer_FDK_AAC HydrogenAudio Knowledgebase: Fraunhofer FDK AAC]. |
| | 16 | |
| | 17 | == Constant Bit Rate (CBR) mode ==#fdk_cbr |
| | 18 | |
| | 19 | These settings target a specific bit rate, with less variation between samples. It gives you greater control over file size, and it is compatible with the HE-AAC profile. As a rule of thumb, for audible transparency, use 64kb/s for each channel (so 128kb/s for stereo, 384 kb/s for 5.1 surround sound). Set the bit rate with the `-b:a` option. |
| | 20 | |
| | 21 | === Examples === |
| 104 | | === Streaming and AAC Player Compatibility ===#fdk_stream |
| 105 | | |
| 106 | | By default when encoding AAC files using libfdk_aac the metadata ('moov' atom) is written after the audio stream ('mdat' atom) at the end of the file. |
| 107 | | In order to enable streaming of the encoded file the 'moov' atom has to be moved before the 'mdat' atom. In addition some AAC player implementations have issues decoding such files. |
| 108 | | |
| 109 | | FFmpeg offers the option '-movflags +faststart' covering that functionality which can be used during encoding: |
| | 108 | ---- |
| | 109 | |
| | 110 | = Native FFmpeg AAC encoder = |
| | 111 | |
| | 112 | The native FFmpeg AAC encoder. This is currently the second highest-quality AAC encoder available in FFmpeg and does not require an external library like the other AAC encoders described here. This is the default AAC encoder. |
| | 113 | |
| | 114 | {{{ |
| | 115 | #!div style="border: 1pt dotted; margin: 1em; background-color: #fffff9;" |
| | 116 | '''Note:''' `-strict experimental` (or `-strict -2`) was previously required for this encoder, but it is [http://git.videolan.org/?p=ffmpeg.git;a=commit;h=d9791a8656b5580756d5b7ecc315057e8cd4255e no longer experimental] and these options are unnecessary since 5 December 2015. |
| | 117 | }}} |
| | 118 | |
| | 119 | == Example using `-b:a` == |
| | 120 | |
| | 121 | {{{ |
| | 122 | ffmpeg -i input.wav -c:a aac -b:a 160k output.m4a |
| | 123 | }}} |
| | 124 | |
| | 125 | == Example using `-q:a` == |
| | 126 | |
| | 127 | {{{ |
| | 128 | ffmpeg -i input.wav -c:a aac -q:a 2 output.m4a |
| | 129 | }}} |
| | 130 | |
| | 131 | Effective range for `-q:a` is around 0.1-2. This VBR is experimental and likely to get even worse results than the CBR. |
| | 132 | |
| | 133 | ---- |
| | 134 | |
| | 135 | = libfaac = |
| | 136 | |
| | 137 | Freeware Advanced Audio Coder. Requires ffmpeg configuration with `--enable-libfaac --enable-nonfree`. Note that you will not get as good results as with `libfdk_aac`. |
| | 138 | |
| | 139 | == Variable Bit Rate (VBR) Example == |
| | 140 | {{{ |
| | 141 | ffmpeg -i input.wav -c:a libfaac -q:a 100 output.m4a |
| | 142 | }}} |
| | 143 | |
| | 144 | Range for `-q:a` is 10-500 and is similar to using the `-q` option in standalone `faac`. 100 is a good value to try. |
| | 145 | |
| | 146 | == Average Bit Rate (ABR) Example == |
| | 147 | {{{ |
| | 148 | ffmpeg -i input.wav -c:a libfaac -b:a 192k output.m4a |
| | 149 | }}} |
| | 150 | |
| | 151 | `libfaac` does not support a true Constant Bit Rate (CBR) mode. |
| | 152 | |
| | 153 | ---- |
| | 154 | |
| | 155 | = Deprecated/removed encoders = |
| | 156 | |
| | 157 | == libvo_aacenc == |
| | 158 | |
| | 159 | !VisualOn AAC encoding library. [http://git.videolan.org/?p=ffmpeg.git;a=commit;h=e07e88cd82f78644ddcb10d7d3e0dd624fffe274 Support for this library has been removed]. Use the native FFmpeg encoder instead: it provides better quality and supports more than 2 channels. |
| | 160 | |
| | 161 | ---- |
| | 162 | |
| | 163 | == libaacplus == |
| | 164 | |
| | 165 | [http://tipok.org.ua/node/17 AAC+] encoding library. [http://git.videolan.org/?p=ffmpeg.git;a=commit;h=9ba54c1b82a81581e5283da75c153a76f04324c0 Support for this library has been removed]. Use `libfdk_aac` instead for HE-AAC: it is consistently better in all bitrates. |
| | 166 | |
| | 167 | ---- |
| | 168 | |
| | 169 | = Metadata = |
| | 170 | |
| | 171 | You can add metadata to any of the examples on this guide: |
| | 172 | |
| | 173 | {{{ |
| | 174 | ffmpeg -i input ... -metadata author="FFmpeg Bayou Jug Band" -metadata title="Decode my Heart (Let's Mux)" output.mp4 |
| | 175 | }}} |
| | 176 | |
| | 177 | ---- |
| | 178 | |
| | 179 | = Progressive download = |
| | 180 | |
| | 181 | By default the MP4 muxer writes the 'moov' atom after the audio stream ('mdat' atom) at the end of the file. This results in the user requiring to download the file completely before playback can occur. Relocating this moov atom to the beginning of the file can facilitate playback before the file is completely downloaded by the client. |
| | 182 | |
| | 183 | You can do this with the `-movflags +faststart` option: |
| 115 | | Existing m4a files can be modified with the "qt-faststart' program which is distributed with FFmpeg in the 'tools' directory |
| 116 | | |
| 117 | | {{{ |
| 118 | | qt-faststart input.m4a output.m4a |
| 119 | | }}} |
| 120 | | |
| 121 | | ---- |
| 122 | | |
| 123 | | == Native FFmpeg AAC encoder == |
| 124 | | |
| 125 | | The native FFmpeg AAC encoder. This is currently the second highest-quality AAC encoder available in FFmpeg and does not require an external library like the other AAC encoders described here. This is the default AAC encoder. |
| 126 | | |
| 127 | | ==== Example using `-b:a` ==== |
| 128 | | |
| 129 | | {{{ |
| 130 | | ffmpeg -i input.wav -b:a 160k output.m4a |
| 131 | | }}} |
| 132 | | |
| 133 | | '''Note:''' `-strict experimental` was previously required for this encoder, but is unneeded since December 2015. |
| 134 | | |
| 135 | | |
| 136 | | ==== Example using `-q:a` ==== |
| 137 | | |
| 138 | | {{{ |
| 139 | | ffmpeg -i input.wav -c:a aac -q:a 2 output.m4a |
| 140 | | }}} |
| 141 | | |
| 142 | | Effective range for `-q:a` is around 0.1-2. This VBR is experimental and likely to get even worse results than the CBR. |
| 143 | | |
| 144 | | ---- |
| 145 | | |
| 146 | | == libfaac == |
| 147 | | |
| 148 | | Freeware Advanced Audio Coder. Requires ffmpeg configuration with `--enable-libfaac --enable-nonfree`. Note that you will not get as good results as with `libfdk_aac`. |
| 149 | | |
| 150 | | ==== Variable Bit Rate (VBR) Example ==== |
| 151 | | {{{ |
| 152 | | ffmpeg -i input.wav -c:a libfaac -q:a 100 output.m4a |
| 153 | | }}} |
| 154 | | |
| 155 | | Range for `-q:a` is 10-500 and is similar to using the `-q` option in standalone `faac`. 100 is a good value to try. |
| 156 | | |
| 157 | | ==== Average Bit Rate (ABR) Example ==== |
| 158 | | {{{ |
| 159 | | ffmpeg -i input.wav -c:a libfaac -b:a 192k output.m4a |
| 160 | | }}} |
| 161 | | |
| 162 | | `libfaac` does not support a true Constant Bit Rate (CBR) mode. |
| 163 | | |
| 164 | | ---- |
| 165 | | |
| 166 | | == libvo_aacenc == |
| 167 | | |
| 168 | | !VisualOn AAC encoding library. [http://git.videolan.org/?p=ffmpeg.git;a=commit;h=e07e88cd82f78644ddcb10d7d3e0dd624fffe274 Support for this library has been removed]. Use the native FFmpeg encoder instead: it provides better quality and supports more than 2 channels. |
| 169 | | |
| 170 | | ---- |
| 171 | | |
| 172 | | == libaacplus == |
| 173 | | |
| 174 | | [http://tipok.org.ua/node/17 AAC+] encoding library. [http://git.videolan.org/?p=ffmpeg.git;a=commit;h=9ba54c1b82a81581e5283da75c153a76f04324c0 Support for this library has been removed]. Use libfdk_aac instead for HE-AAC: is consistently better in all bitrates. |
| 175 | | |
| 176 | | ---- |
| 177 | | |
| 178 | | == Metadata == |
| 179 | | You can add metadata to any of the examples on this guide: |
| 180 | | |
| 181 | | {{{ |
| 182 | | ffmpeg -i input ... -metadata author="FFmpeg Bayou Jug Band" -metadata title="Decode my Heart (Let's Mux)" output.mp4 |
| 183 | | }}} |
| 184 | | |
| 185 | | ---- |
| 186 | | |
| 187 | | == FAQ == |
| 188 | | === Which encoder should I use? What provides the best quality? === |
| | 189 | You can also use this option on existing MP4/M4A files. Since the audio is simply being [https://ffmpeg.org/ffmpeg.html#Stream-copy stream copied] there is no re-encoding occurring, just re-muxing, so therefore there is no quality loss: |
| | 190 | |
| | 191 | {{{ |
| | 192 | ffmpeg -i input.m4a -c:a copy -movflags +faststart output.m4a |
| | 193 | }}} |
| | 194 | |
| | 195 | ---- |
| | 196 | |
| | 197 | = FAQ = |
| | 198 | |
| | 199 | == Which encoder provides the best quality? == |