Repository navigation
Filter rubberband
rubberband changes the tempo and the pitch of audio, each on its own. It uses the Rubber Band library (version 4.0.0). It can keep the formants, so voices still sound natural after a pitch change.
atempo only changes the tempo. Use rubberband when you need the pitch too, or the R3 engine.
Since: v1.0.49, on all seven platforms.
# 5 % faster, same key
ffmpeg -i in.flac -af rubberband=tempo=1.05 out.flac
# One semitone up, same length
ffmpeg -i in.flac -af rubberband=pitch=1.0595 out.flac
# The same, with the R3 engine (better quality, more CPU)
ffmpeg -i in.flac -af rubberband=pitch=1.0595:engine=finer out.flacA semitone is a factor of 1.0595 (the twelfth root of 2). Two semitones down is pitch=0.8909.
| Stock FFmpeg | NoMercy FFmpeg | |
|---|---|---|
| Engine | R2 only |
engine=faster (R2, the default) or engine=finer (R3) |
| Start of the output | Late by the stretcher's start delay: up to 32.5 ms at pitch=0.5 and 15.3 ms at tempo=2 in our measurements |
In step with the input: within 4.7 ms (R2) or 4.1 ms (R3), the stretcher's own window smear |
| Length of the output | Not exact | Exactly input length ÷ tempo samples, at a fixed tempo |
The start and the length matter when you line up a stretched track with another one, for example in a DJ mix.
The table is copied from ffmpeg -h filter=rubberband of v1.0.49.
| Option | Type | Default | What it does |
|---|---|---|---|
tempo |
double | 1 |
Tempo factor. 2 is twice as fast. Range: 0.01 to 100. Can be changed while running. |
pitch |
double | 1 |
Pitch factor. 2 is one octave up. Range: 0.01 to 100. Can be changed while running. |
transients |
flags | crisp |
How sharp sounds such as drum hits are treated: crisp, mixed or smooth. R2 only. |
detector |
flags | compound |
Which kind of transient is detected: compound, percussive or soft. R2 only. |
phase |
flags | laminar |
laminar or independent. R2 only. |
window |
flags | standard |
Analysis window: standard, short or long. |
smoothing |
flags | off |
off or on. R2 only. |
formant |
flags | shifted |
preserved keeps the formants on a pitch change. |
pitchq |
flags | speed |
Pitch quality: speed, quality or consistency. |
channels |
flags | apart |
together keeps the stereo image tighter. |
engine |
flags | faster |
faster is R2, the engine of Rubber Band 2. finer is R3: higher quality, more CPU. NoMercy only.
|
tempo and pitch are runtime commands, so sendcmd or asendcmd can change them mid-stream. The exact length only holds for a tempo that does not change.
The smoke test and the manual suite check each platform:
- the output length is exactly input length ÷ tempo;
- a sine that starts at 1 s in the input starts within 10 ms of 1 ÷ tempo in the output;
- the spectral centre of a 440 Hz sine sits at 440 Hz × pitch in every window;
-
engine=fasterandengine=finergive different bytes.
Users
Filters and components
- Filter-stemsplit
- Filter-lyricsalign
- Whisper-Language-Detection
- Whisper-Word-Timestamps
- Filter-trailingsilence
- Filter-keydetect
- Filter-beatdetect
- Filter-rubberband
- Muxer-Sprite-Sheet
- Muxer-Chapter-VTT
- Muxer-VOBsub
- Protocol-dvdread
- Protocol-OmniDrive
- Auto-Create-Directories
- AACS-and-BDplus
- HLS-Master-Playlist
- Subtitles-OCR
- HEVC-Alpha
Acceleration and codecs
Contributors