wiki:

Encode

/

HighQualityAudio


Version 2 (modified by lithosza, 6 years ago) (diff)

--

Guidelines for high quality audio encoding

This guide is meant to help people new to encoding audio to use the correct encoders and settings.

When should I transcode audio?

Avoid transcoding from lossy to lossy if possible. Use the lossless source(if you have it) or just don't transcode by copying the source audio track.

Generation loss

Transcoding from a lossy format like(MP3,AAC,Vorbis,Opus,WMA etc.) to the same or different lossy format might degrade the audio quality even if the bitrate stays the same(or higher). This quality degradation might not be audible to you but it might be audible to others.
This post on hydrogenaudio.org demonstrates what will happen if you transcode a file 100 times: http://www.hydrogenaudio.org/forums/index.php?showtopic=100067

Copying audio tracks

If the target container format supports the audio codec of the source file then really consider just muxing it into the output file. MKV supports virtually any audio codec.
This can be achieved by specifying 'copy' as the audio codec. Example:
Transcoding a WebM file with a VP8 video track and Vorbis track to a MKV file with H.264 video track and Vorbis audio track:

ffmpeg -i someFile.webm -c:a copy -c:v libx264 outFile.mkv

In some cases this might not be possible, because the target device doesn't support the codec or the target container format doesn't support the codec.
Another reason to transcode might be that the source audio track is too big. (It has a higher bitrate than what you want in the output file)

Audio encoders ffmpeg can use

ffmpeg can encode to a wide variery of audio formats.

Here are some popular formats with encoders listed that ffmpeg can use:

LC-AAC: libfdk_aac, faac, aac, libvo_aacenc
HE-AAC: libfdk_aac, libaacplus
Vorbis: libvorbis
MP3: libmp3lame
Opus: libopus

Based on quality produced from high to low:

libopus >= libfdk_aac >= libvorbis >= libmp3lame > libfaac > Native FFmpeg AAC >= libvo_aacenc

Even though AAC should generally give better quality than MP3 at the same bitrates libmp3lame should give better quality output than libfaac.

Please note it is not recommended to use (libfaac/Native FFmpeg AAC/libvo_aacenc) for AAC encoding.

Container formats

Only certain audio codecs will be able to fit in your target output file.

ContainerAudio formats supported
MKVVorbis,MP3,LC-AAC,HE-AAC
MP4MP3,LC-AAC,HE-AAC
WebMVorbis
OGGVorbis,Opus

Please note that there more container formats available than those listed above.

Recommended minimum bitrates to use

Please note that the bitrates listed here assumes the audio is Stereo and >= 44.1Khz. Mono could require less bits.

  • libopus Recommended usable range >= 64Kbps. Reaching transparency around 96Kbps
  • (libfdk_aac or libaacplus) -profile:a aac_he_v2 Recommended usable range <= 48Kbps CBR. Transparency: Does not reach transparency. Use LC-AAC instead to achieve transparency
  • (libfdk_aac or libaacplus) -profile:a aac_he Recommended usable range >= 48Kbps and <= 80Kbps CBR. Transparency: Does not reach transparency. Use LC-AAC instead to achieve transparency
  • libfdk_aac default LC-AAC profile. Recommended usable range VBR level 3 to 5 (http://ffmpeg.org/trac/ffmpeg/wiki/AACEncodingGuide). Reaching transparency around VBR level 3 (Around 96Kbps)
  • libvorbis Recommended usable range >= 96Kbps. Reaching transparency around 96Kbps
  • libmp3lame Recommended usable range >= 128Kbps. Reaching transpareny around 128Kbps
  • libfaac Recommended usable range ????kbps. Requires testing
  • aac Recommended usable range ????kbps. Requires testing
  • libvo_aacenc Recommended usable range ????kbps. Requires testing

Please note Opus streams are currently not muxable in MKV containers. Only Ogg Containers at the moment.
When compatibility with hardware players doesn't matter then use libvorbis in a MKV container rather than libfaac when libfdk_aac isn't available
When compatibility with hardware players does matter then use libmp3lame in a MP4/MKV container rather than libfaac when libfdk_aac isn't available
Transparency means the encoded audio sounds indistinguishable from the source file.