How to Use the FFmpeg Rubberband Filter
This article provides a quick guide on how to use the
rubberband audio filter in FFmpeg to change the pitch and
tempo of an audio file independently. You will learn how to configure
the filter, understand its primary parameters, and apply practical
command-line examples to stretch time or shift pitch without causing
distortion.
Prerequisites
To use this filter, your FFmpeg build must be compiled with the
librubberband library enabled. You can check if your FFmpeg
installation supports it by running:
ffmpeg -filters | grep rubberbandIf the output lists rubberband, you are ready to
proceed.
Basic Syntax and Parameters
The rubberband filter relies on two primary parameters
to control audio manipulation:
tempo: Adjusts the speed of the audio. A value of1.0is normal speed. Values greater than1.0speed up the audio, while values less than1.0slow it down.pitch: Adjusts the pitch scale. A value of1.0is the original pitch. Values greater than1.0raise the pitch, while values less than1.0lower it.
Practical Examples
1. Change Tempo (Speed) Without Affecting Pitch
To speed up an audio file by 1.5 times the original speed while maintaining its original pitch, use the following command:
ffmpeg -i input.mp3 -af "rubberband=tempo=1.5" output.mp3To slow down the audio to 80% of its original speed:
ffmpeg -i input.mp3 -af "rubberband=tempo=0.8" output.mp32. Change Pitch Without Affecting Tempo
To raise the pitch of an audio track by 1.25 times without altering its speed, use:
ffmpeg -i input.mp3 -af "rubberband=pitch=1.25" output.mp3To lower the pitch to 75% of its original frequency:
ffmpeg -i input.mp3 -af "rubberband=pitch=0.75" output.mp33. Adjust Both Tempo and Pitch Simultaneously
You can combine both parameters to modify speed and pitch at the same time by separating the arguments with a colon:
ffmpeg -i input.mp3 -af "rubberband=tempo=1.2:pitch=0.85" output.mp3Additional Options
The rubberband filter also supports options for
fine-tuning the audio quality based on the type of source material:
transients: Controls how transients (sharp, fast sound starts like drums) are treated. Options includecrisp,mixed, andsmooth.detector: Sets the onset detection engine. Options arecompound,quality, andtypical.
Example of a high-quality setting for percussive music:
ffmpeg -i input.wav -af "rubberband=tempo=1.2:transients=crisp" output.wav