How to Decode HDCD Audio Using FFmpeg
High Definition Compatible Digital (HDCD) encodes 20 bits of audio
data into standard 16-bit Red Book audio tracks using hidden control
instructions for peak extension and gain matching. This article
demonstrates how to use FFmpeg's built-in hdcd audio filter
to identify HDCD-encoded files, properly decode the hidden dynamic
range, and export the resulting audio to a 24-bit lossless format.
Checking for HDCD Data
Before converting, you can analyze an audio file to determine if it contains HDCD instructions without generating a new file. Run the following command:
ffmpeg -i input.wav -af hdcd -f null -Inspect the terminal output under the [hdcd ...] logging
block. Look for the HDCD detected: line. If it reports
yes, the track contains HDCD features such as
peak_extend or gain_adj.
Basic Decoding to 24-Bit FLAC
The hdcd filter converts 16-bit PCM samples into a
32-bit integer internal format to accommodate the expanded 20-bit
dynamic range. To preserve this added dynamic range, output the audio
into a format capable of storing higher bit depths, such as a 24-bit
FLAC or WAV:
ffmpeg -i input.wav -af hdcd -c:a flac output.flacBecause FLAC defaults to encoding at the highest sample format provided by the filter chain, this command automatically produces a 24-bit FLAC file containing the fully decoded 20-bit audio stream.
Key Filter Parameters
The hdcd filter provides several parameters to control
how decoding occurs:
process_pe: Controls Peak Extend processing. By default, it is enabled (process_pe=1). Setting it to0disables peak expansion while keeping other HDCD metadata processing intact.analyze_mode: Useful for troubleshooting or monitoring. Settinganalyze_mode=1injects audible tones or clips samples to highlight where HDCD features are triggered. Default is0(off).bits_per_raw_sample: Specifies the bit depth of the output. When set to0(default), the filter sets the output precision dynamically based on whether HDCD data was found.
To disable peak extend manually:
ffmpeg -i input.wav -af "hdcd=process_pe=0" -c:a flac output.flacDecoding to 24-Bit WAV
If you prefer uncompressed 24-bit PCM WAV as your output format,
explicitly set the sample format to 24-bit signed little-endian PCM
(pcm_s24le):
ffmpeg -i input.wav -af hdcd -c:a pcm_s24le output.wavBatch Processing Considerations
When processing entire albums, note that some releases only activate
peak extension on specific tracks. FFmpeg's hdcd filter
processes audio on a per-file basis, ensuring that non-HDCD tracks pass
through safely while HDCD-encoded tracks have their extra dynamic range
restored.