How to Use the FFmpeg bs2b Filter
The bs2b (Bauer stereophonic-to-binaural) filter in
FFmpeg is an audio filter designed to improve headphone listening by
processing stereo audio into a binaural signal. This article explains
how the filter works, how to verify your FFmpeg installation supports
it, and how to apply the filter using various built-in presets and
custom parameters to reduce headphone listening fatigue.
What is the bs2b Filter?
When listening to stereo audio through headphones, the extreme
channel separation (where the left channel only reaches the left ear,
and the right channel only reaches the right ear) can cause acoustic
fatigue. The bs2b filter applies a crossfeed effect, mixing
a delayed and attenuated portion of each channel into the opposite
channel. This emulates how we naturally hear stereo speakers in a room,
creating a more cohesive, natural, and comfortable soundstage.
Verification
Before using the filter, ensure your version of FFmpeg was compiled
with libbs2b support. Run the following command in your
terminal:
ffmpeg -filters | grep bs2bIf the output lists bs2b, the filter is available. If no
output appears, you must install or compile a version of FFmpeg that
includes the --enable-libbs2b configuration flag.
Basic Usage
To apply the bs2b filter using its default settings, use
the audio filter (-af) flag in your command:
ffmpeg -i input.mp3 -af bs2b output.mp3Using Built-in Presets
The bs2b filter includes built-in profiles based on
popular hardware crossfeed circuit designs. You can specify these
profiles using the profile parameter:
- default: The standard Bauer stereophonic-to-binaural settings (cut frequency: 700 Hz, crossfeed: 4.5 dB).
- cmoy: Emulates the Chu Moy headphone amplifier crossfeed circuit (cut frequency: 700 Hz, crossfeed: 6.0 dB).
- jmeier: Emulates the Jan Meier crossfeed circuit (cut frequency: 650 Hz, crossfeed: 9.5 dB).
To apply the Chu Moy preset, use:
ffmpeg -i input.wav -af bs2b=profile=cmoy output.wavTo apply the Jan Meier preset, use:
ffmpeg -i input.wav -af bs2b=profile=jmeier output.wavCustom Parameter Configuration
If you want to fine-tune the crossfeed effect beyond the presets, you
can manually set the low-pass filter cut frequency (fcut)
and the feed level (feed):
- fcut: Sets the cut frequency in Hz (allowable range: 385 to 1000).
- feed: Sets the feed level in tenths of a decibel (allowable range: 10 to 150, representing 1.0 to 15.0 dB).
To configure a custom setup with a cut frequency of 750 Hz and a feed
level of 5.0 dB (entered as 50):
ffmpeg -i input.mp3 -af bs2b=fcut=750:feed=50 output.mp3