How to Use FFmpeg Rubberband Filter to Stretch Audio
This guide provides a straightforward walkthrough on using FFmpeg's
librubberband filter to time-stretch audio without altering
its pitch. You will learn the necessary prerequisites, the core command
syntax for speeding up or slowing down audio, and the primary parameters
available for fine-tuning sound quality.
Prerequisites
To use this filter, your FFmpeg build must be compiled with
librubberband support. You can verify this by running:
ffmpeg -filters | grep rubberbandIf rubberband appears in the output, your installation
is ready.
Basic Time-Stretching Syntax
The rubberband audio filter changes the tempo
independently of pitch. The primary parameter used for stretching is
tempo.
To slow audio down (stretching its duration):
ffmpeg -i input.wav -af "rubberband=tempo=0.8" output.wavA tempo value of 0.8 slows the audio down to 80% of
its original speed, extending the playback time.
To speed audio up (compressing its duration):
ffmpeg -i input.wav -af "rubberband=tempo=1.5" output.wavA tempo value of 1.5 plays the audio at 150% speed,
shortening the playback time.
Adjusting Pitch Independently
While standard stretching preserves the original pitch, you can also
alter pitch explicitly using the pitch parameter (expressed
as a scale factor, where 1.0 is original pitch,
2.0 is an octave up, and 0.5 is an octave
down):
ffmpeg -i input.wav -af "rubberband=tempo=0.75:pitch=1.2" output.wavYou can also specify pitch shifts in semitones using
pitchq:
ffmpeg -i input.wav -af "rubberband=tempo=0.5:pitchq=2" output.wavThis slows the audio to half speed and shifts the pitch up by two semitones.
Fine-Tuning Audio Quality
Rubberband includes processing modes optimized for different types of audio material:
- transients: Controls how transient sounds (like
drum hits) are handled. Options include
crisp,mixed, orsmooth. - detector: Specifies the onset detector component
(
compound,percussive, orsoft).
Example for percussive or drum-heavy audio:
ffmpeg -i drums.wav -af "rubberband=tempo=0.7:transients=crisp:detector=percussive" drums_slow.wavExample for smooth, ambient, or orchestral audio:
ffmpeg -i ambient.wav -af "rubberband=tempo=0.6:transients=smooth:detector=soft" ambient_stretched.wav