How to Decode HDCD Audio with FFmpeg
This article provides a straightforward guide on how to use the
FFmpeg hdcd audio filter to decode 20-bit High Definition
Compatible Digital (HDCD) data embedded in 16-bit audio files. You will
learn the exact command-line syntax required to detect and extract this
high-resolution audio, along with the key parameters available to
customize the decoding process.
High Definition Compatible Digital (HDCD) is a process that encodes
20-bit audio data into standard 16-bit Red Book CD audio using
sub-audible control signals. To play this audio back at its original
20-bit resolution, you must decode it. FFmpeg includes a built-in
hdcd filter that detects these control signals and expands
the dynamic range, outputting a high-resolution 24-bit or 32-bit audio
file.
The Basic Decoding Command
To decode an HDCD-encoded file (such as a 16-bit FLAC or WAV file ripped from an HDCD CD) and save it as a lossless 24-bit file, use the following FFmpeg command:
ffmpeg -i input_16bit.flac -af hdcd output_24bit.flacIn this command: * -i input_16bit.flac: Specifies your
source 16-bit HDCD file. * -af hdcd: Applies the HDCD
filter. FFmpeg will automatically detect the HDCD features (such as Peak
Extend and Low-level Range Gain) and decode the audio into 32-bit
integer format (s32). * output_24bit.flac:
Saves the result. Because FLAC supports up to 24-bit audio, saving to
FLAC automatically compresses the 32-bit decoded stream down to 24-bit
depth, preserving all 20 bits of the decoded HDCD data.
If you prefer to output to a 24-bit WAV file instead of FLAC, you must explicitly set the audio codec to 24-bit PCM:
ffmpeg -i input_16bit.wav -af hdcd -c:a pcm_s24le output_24bit.wavChecking if a File Has HDCD Encoding
If you want to verify whether a CD rip actually contains HDCD encoding without writing a new file, you can run the filter in analyze mode. Run the following command:
ffmpeg -i input_16bit.flac -af hdcd -f null -After the process finishes, look at the console output. FFmpeg will
display statistics about the HDCD stream. If the output shows
unsupported or no HDCD detected, the source
file is standard 16-bit audio. If it displays active features like
Peak Extend: Enabled or
Transient Filter: Detected, the file contains HDCD
data.
Advanced HDCD Filter Options
The hdcd filter has optional parameters that allow you
to control how the decoding behaves. You can pass these options using
the syntax -af hdcd=parameter=value.
disable_esfilter: Disables the packet steering filter. Some HDCD discs use packet steering to alternate processing parameters.
ffmpeg -i input.flac -af hdcd=disable_esfilter=1 output.flacprocess_stereo: Processes both channels of a stereo file independently. This is enabled (
1) by default. Setting it to0forces mono processing.analyze_mode: Allows you to visualize or analyze HDCD features by replacing the audio output with a visual representation of when Peak Extend or Transient Filtering is active. This is primarily used for debugging. Options include
0(disabled/default),1(gain),2(transient), or3(all).