| 33 | | Here are some popular lossy formats with encoders listed that FFmpeg can use:[[BR]] |
| 34 | | {{{ |
| 35 | | Dolby Digital: ac3 |
| 36 | | Dolby Digital Plus: eac3 |
| 37 | | TrueHD 0xFBA: truehd |
| 38 | | MP2: libtwolame, mp2 |
| 39 | | Windows Media Audio 1: wmav1 |
| 40 | | Windows Media Audio 2: wmav2 |
| 41 | | AAC LC: libfdk_aac, aac |
| 42 | | HE-AAC: libfdk_aac |
| 43 | | Vorbis: libvorbis, vorbis |
| 44 | | MP3: libmp3lame, libshine |
| 45 | | Opus: libopus |
| 46 | | }}} |
| 47 | | Based on quality produced from high to low:[[BR]] |
| 48 | | {{{ |
| 49 | | libopus > libvorbis >= libfdk_aac > libmp3lame >= eac3/ac3 > aac > libtwolame > vorbis > mp2 > wmav2/wmav1 |
| 50 | | }}} |
| | 34 | |
| | 35 | == Audio encoders FFmpeg can use == #Encoders |
| | 36 | |
| | 37 | ͏ FFmpeg can encode to a wide variety of lossy audio formats.\\ |
| | 38 | ͏ Here are some popular lossy formats with encoders listed that FFmpeg can use:\\ |
| | 39 | ͏ **Opus**: "libopus"\\ |
| | 40 | ͏ **Vorbis**: "libvorbis", "vorbis"\\ |
| | 41 | ͏ **AAC LC**: "libfdk_aac", "aac"\\ |
| | 42 | ͏ **HE-AAC**: "libfdk_aac"\\ |
| | 43 | ͏ **MP3**: "libmp3lame", "libshine"\\ |
| | 44 | ͏ **Dolby Digital**: "ac3"\\ |
| | 45 | ͏ **Dolby Digital Plus**: "eac3"\\ |
| | 46 | ͏ **TrueHD 0xFBA**: "truehd"\\ |
| | 47 | ͏ **MP2**: "libtwolame", "mp2"\\ |
| | 48 | ͏ **Windows Media Audio 1**: "wmav1"\\ |
| | 49 | ͏ **Windows Media Audio 2**: "wmav2" |
| | 50 | |
| | 51 | ͏ Based on quality produced from high to low:\\ |
| | 52 | ͏ "libopus" > "libvorbis" >= "libfdk_aac" > "libmp3lame" >= "eac3"/"ac3" > "aac" > "libtwolame" > "vorbis" > "mp2" > "wmav2"/"wmav1" |
| | 53 | |
| 74 | | == Container formats == |
| 75 | | Only certain audio codecs will be able to fit in your target output file. |
| 76 | | ||'''Container'''||'''Audio formats supported'''|| |
| 77 | | ||'''MKV/MKA'''||Opus, Vorbis, MP2, MP3, LC-AAC, HE-AAC, WMAv1, WMAv2, AC3, E-AC3, TrueHD|| |
| 78 | | ||'''MP4/M4A'''||Opus, MP2, MP3, LC-AAC, HE-AAC, AC3, E-AC3, TrueHD|| |
| 79 | | ||'''FLV/F4V'''||MP3, LC-AAC, HE-AAC|| |
| 80 | | ||'''3GP/3G2'''||LC-AAC, HE-AAC|| |
| 81 | | ||'''MPG'''||MP2, MP3|| |
| 82 | | ||'''PS/TS Stream'''||MP2, MP3, LC-AAC, HE-AAC, AC3, TrueHD|| |
| 83 | | ||'''M2TS'''||AC3, E-AC3, TrueHD|| |
| 84 | | ||'''VOB'''||MP2, AC3|| |
| 85 | | ||'''RMVB'''||Vorbis, HE-AAC|| |
| 86 | | ||'''WebM'''||Vorbis, Opus|| |
| 87 | | ||'''OGG'''||Vorbis, Opus|| |
| 93 | | The bitrates listed here assume 2-channel stereo and a sample rate of 44.1kHz or 48kHz. Mono, speech, and quiet audio may require fewer bits. |
| | 82 | ͏ **Container**: **Audio formats supported**\\ |
| | 83 | ͏ **MKV/MKA**: Opus, Vorbis, MP2, MP3, LC-AAC, HE-AAC, WMAv1, WMAv2, AC3, E-AC3, TrueHD\\ |
| | 84 | ͏ **MP4/M4A**: Opus, MP2, MP3, LC-AAC, HE-AAC, AC3, E-AC3, TrueHD\\ |
| | 85 | ͏ **FLV/F4V**: MP3, LC-AAC, HE-AAC\\ |
| | 86 | ͏ **3GP/3G2**: LC-AAC, HE-AAC\\ |
| | 87 | ͏ **MPG**: MP2, MP3\\ |
| | 88 | ͏ **PS/TS Stream**: MP2, MP3, LC-AAC, HE-AAC, AC3, TrueHD\\ |
| | 89 | ͏ **M2TS**: AC3, E-AC3, TrueHD\\ |
| | 90 | ͏ **VOB**: MP2, AC3\\ |
| | 91 | ͏ **RMVB**: Vorbis, HE-AAC\\ |
| | 92 | ͏ **WebM**: Vorbis, Opus\\ |
| | 93 | ͏ **OGG**: Vorbis, Opus |
| 95 | | - '''libopus''' – usable range ≥ 32Kbps. Recommended range ≥ 64Kbps.[[BR]]Transparency (music): very close at default (96 Kbps), but takes more (160+) to be real transparent.[[br]]Speech: Transparent at 32 Kbps. See [https://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio] bitrate notes. |
| 96 | | - '''libfdk_aac default AAC LC profile''' – recommended range ≥ 128Kbps; see [[Encode/AAC|AAC Encoding Guide]]. |
| 97 | | - '''libfdk_aac -profile:a aac_he_v2''' – usable range ≤ 48Kbps CBR.[[BR]]Transparency: Does not reach transparency. Use AAC LC instead to achieve transparency |
| 98 | | - '''libfdk_aac -profile:a aac_he''' – usable range ≥ 48Kbps and ≤ 80Kbps CBR.[[BR]]Transparency: Does not reach transparency. Use AAC LC instead to achieve transparency |
| 99 | | - '''libvorbis''' – usable range ≥ 96Kbps. Recommended range `-aq 4` (≥ 128Kbps). Neither high quality nor widely supported, avoid. |
| 100 | | - '''libmp3lame''' – usable range ≥ 128Kbps. Recommended range `-aq 2` (≥ 192Kbps) |
| 101 | | - '''ac3 or eac3''' – usable range ≥ 160Kbps. Recommended range ≥ 160Kbps |
| 102 | | Example of usage: |
| 103 | | {{{ |
| 104 | | ffmpeg -i input.wav -c:a ac3 -b:a 160k output.m4a |
| 105 | | }}} |
| 106 | | - '''aac''' – usable range ≥ 32Kbps (depending on profile and audio). Recommended range ≥ 128Kbps[[BR]]Example of usage: |
| 107 | | {{{ |
| 108 | | ffmpeg -i input.wav -c:a aac -b:a 128k output.m4a |
| 109 | | }}} |
| 110 | | - '''libtwolame''' – usable range ≥ 192Kbps. Recommended range ≥ 256Kbps |
| 111 | | - '''mp2''' – usable range ≥ 320Kbps. Recommended range ≥ 320Kbps[[BR]] |
| | 95 | ͏ There are more container formats available than those listed above, like MXF.\\ |
| | 96 | ͏ Also, E-AC3 is only officially (according to Dolby) supported in MP4 (for example, E-AC3 needs editlist to remove padding of initial 256 silence samples). |
| 117 | | To calculate the bitrate to use for multi-channel audio: (bitrate for stereo) x (channels / 2).[[BR]] |
| 118 | | Example for 5.1 (6 channels) Vorbis audio: 128Kbps x (6 / 2) = 384Kbps[[BR]] |
| | 99 | == Recommended minimum bit rates to use == #Recommended |
| | 100 | |
| | 101 | ͏ The bit rates listed here assume Stereo (2 ch) and sample rate of 44.1 KHz or 48 KHz.\\ |
| | 102 | ͏ Mono, speech, and quiet audio tend to require fewer bits. |
| | 103 | |
| | 104 | - **"libopus"** - Usable range ≥ 32 Kbps. Recommended range ≥ 64 Kbps.\\ |
| | 105 | Transparency (music): very close at default (96 Kbps), but takes more (160+) to be real transparent.\\ |
| | 106 | Transparency (speech): ~ 32 Kbps.\\ |
| | 107 | See also: https://wiki.hydrogenaud.io/?title=Opus |
| | 108 | - **"libfdk_aac"** (default profile AAC LC) - Recommended range ≥ 128 Kbps; see <[[Encode/AAC]]>. |
| | 109 | - **"libfdk_aac" -profile:a aac_he_v2** - Usable range ≤ 48 Kbps CBR.\\ |
| | 110 | Transparency: Does not reach transparency. Use AAC LC instead to achieve transparency. |
| | 111 | - **"libfdk_aac" -profile:a aac_he** - Usable range ≥ 48 Kbps and ≤ 80 Kbps CBR.\\ |
| | 112 | Transparency: Ditto. |
| | 113 | - **"libvorbis"** - Usable range ≥ 96 Kbps. Recommended range "-aq 4" (≥ 128 Kbps).\\ |
| | 114 | Neither high quality nor widely supported, avoid. |
| | 115 | - **"libmp3lame"** - Usable range ≥ 128 Kbps. Recommended range "-aq 2" (≥ 192 Kbps) |
| | 116 | - **"ac3"** or **"eac3"** - Usable range ≥ 160 Kbps. Recommended range ≥ 160 Kbps\\ |
| | 117 | E.g. `ffmpeg -i "${In}" -c:a ac3 -b:a 160k "${Out}"` |
| | 118 | - **"aac"** - Usable range ≥ 32 Kbps (depending on profile and audio). Recommended range ≥ 128 Kbps\\ |
| | 119 | E.g. `ffmpeg -i "${In}" -c:a aac -b:a 128k "${Out}"` |
| | 120 | - **"libtwolame"** - Usable range ≥ 192 Kbps. Recommended range ≥ 256 Kbps |
| | 121 | - **"mp2"** - Usable range ≥ 320 Kbps. Recommended range ≥ 320 Kbps |
| | 122 | |
| | 123 | ͏ "**vorbis**" and "**wmav1**"/"**wmav2**" encoders are not worth using.\\ |
| | 124 | ͏ "**wmav1**"/"**wmav2**" encoder **does not reach transparency at any bit rate**.\\ |
| | 125 | ͏ "**vorbis**" encoder does not use the bit rate specified in FFmpeg:\\ |
| | 126 | ͏ On some samples it does sound reasonable, but the bit rate is very high. |
| | 127 | |
| | 128 | ͏ To estimate the bit rate for multi-channel audio:\\ |
| | 129 | ͏ ${Stereo Bitrate}/2 * ${Channel#}\\ |
| | 130 | ͏ .\\ |
| | 131 | ͏ E.g. 5.1 (6 ch) Vorbis audio: 128/2 * 6 = 384 Kbps |
| | 132 | |
| 126 | | Some codecs have a more efficient variable bitrate (VBR) mode which optimizes to a given, constant quality level rather than having variable quality at a given, constant bitrate (CBR). The info above is for CBR. VBR is more efficient than CBR but may not be as hardware-compatible (this mainly applies to older formats, i.e. not Opus). |
| | 140 | ͏ Some codecs have a more efficient Variable Bit Rate (VBR) mode: which optimizes to a given, constant quality level; rather than having variable quality at a given, Constant Bit Rate (CBR).\\ |
| | 141 | ͏ The info above mainly targeted CBR.\\ |
| | 142 | ͏ VBR is more efficient than CBR, but may not be as hardware-compatible. (mainly applies to antique formats: irrelevant Opus alike) |
| | 143 | |
| 130 | | * [http://opus-codec.org/comparison/ Opus – Codec Landscape] |
| 131 | | * [https://ghostarchive.org/archive/UvXHR xiph.org – 64kbit/sec stereo multiformat listening test] including Opus, aoTuV Vorbis, two HE-AAC encoders, and a 48kbit/sec AAC-LC low anchor |
| 132 | | * [http://listening-test.coresv.net/results.htm#list9 Results of the public multiformat listening test (July 2014)] – Opus, AAC and Ogg Vorbis at 96 kbps against a classic MP3 128 kbps |
| 133 | | * [http://opus-codec.org/static/comparison/GoogleTest1.pdf Google Listening Test #1] – comparing Opus, Speex, and others |
| 134 | | * [http://opus-codec.org/static/comparison/GoogleTest2.pdf Google Listening Test #2] – comparing Opus, Speex, and others |
| | 147 | * https://opus-codec.org/comparison/ |
| | 148 | * Google Listening Test !#1 - comparing Opus, Speex, and others\\ |
| | 149 | https://opus-codec.org/static/comparison/GoogleTest1.pdf |
| | 150 | * Google Listening Test !#2\\ |
| | 151 | https://opus-codec.org/static/comparison/GoogleTest2.pdf |
| | 153 | * [2011] 64 Kbps Stereo multi-format listening test\\ |
| | 154 | https://web.archive.org/web/20200202080247/https://people.xiph.org/~greg/opus/ha2011/\\ |
| | 155 | !^ Of Opus, aoTuV Vorbis, 2 HE-AAC encoders, and a 48 Kbps AAC-LC low anchor. |
| | 156 | * [201407] Results of the public multi-format listening test\\ |
| | 157 | https://listening-test.coresv.net/results.htm#list9\\ |
| | 158 | !^ Opus, AAC, Vorbis at 96 Kbps against typical MP3 128 Kbps. |