How to Decode HDCD Audio Using FFmpeg
High-Definition Compatible Digital (HDCD) is a proprietary encoding
process that embeds 20-bit audio data into standard 16-bit CD quality
tracks. To experience the full dynamic range of an HDCD-encoded audio
file on modern playback systems, the audio must be decoded back into a
high-resolution format. This article provides a direct, step-by-step
guide on how to use FFmpeg’s built-in hdcd filter to detect
HDCD encoding and decode your audio files into 24-bit lossless
files.
Step 1: Detect if a File Has HDCD Encoding
Before decoding, you should verify whether your audio file actually contains HDCD information. Many CDs were pressed without HDCD, and applying the filter to standard audio is unnecessary.
Run the following command to analyze the file without writing a new output file:
ffmpeg -i input.wav -af hdcd=detect_only=1 -f null -Understanding the Output
Look at the console output at the end of the process. FFmpeg will display a summary report. Look for these key indicators: * HDCD detected: If this says “yes”, the file contains HDCD data. * Peak extend: Indicates if the dynamic range extension feature was used (Yes/No). * Transient filter: Indicates if the filter switching feature was used.
If the output shows no HDCD packets detected, you do not need to decode the file.
Step 2: Decode HDCD to a Lossless 24-bit File
To decode the 20-bit HDCD data, you must output the file to a format that supports greater than 16-bit depth (such as 24-bit FLAC or 24-bit WAV) to preserve the expanded dynamic range.
Option A: Decode to 24-bit FLAC (Recommended)
FLAC is compressed and lossless, making it ideal for storing decoded high-resolution audio.
ffmpeg -i input.wav -af hdcd -c:a flac output.flacOption B: Decode to 24-bit WAV
If you prefer uncompressed PCM audio, convert the file to a 24-bit WAV file:
ffmpeg -i input.wav -af hdcd -c:a pcm_s24le output.wavAdvanced Filter Options (Optional)
The hdcd filter allows you to customize the decoding
process using specific parameters. You can append these to the
-af hdcd flag, separated by colons.
process_stereo: By default, FFmpeg processes both channels. You can force mono processing or disable it entirely.- Example:
-af hdcd=process_stereo=1(Default/Enabled)
- Example:
force_pe: Force peak extend decoding even if the stream does not explicitly flag it (not recommended unless you know the flags are missing).- Example:
-af hdcd=force_pe=1
- Example:
analyze_mode: For debugging purposes, this highlights where HDCD features are being active by altering the audio output.- Example:
-af hdcd=analyze_mode=0(Disabled, default) or1(visualized gain adjustment).
- Example: