How to Combine Rubberband and Scale in FFmpeg

This article explains how to combine the rubberband audio filter and the video scale filter in a single FFmpeg command. You will learn the correct command-line syntax to simultaneously resize your video and adjust its audio pitch or tempo using both simple filter arguments and complex filtergraphs.

Prerequisites

To use the rubberband filter, your FFmpeg build must be compiled with the --enable-librubberband configuration flag. You can verify this by running ffmpeg -filters and checking if rubberband is listed.


Method 1: Using Separate -vf and -af Flags

The simplest way to combine these two operations is by using the video filter (-vf) and audio filter (-af) flags in a single command. This method is ideal when you have a single input stream and want to output a single file.

Command Example

ffmpeg -i input.mp4 -vf "scale=1280:720" -af "rubberband=tempo=1.5:pitch=1.2" output.mp4

Parameter Breakdown

  • -i input.mp4: Specifies the source video file.
  • -vf "scale=1280:720": Resizes the video to a width of 1280 pixels and a height of 720 pixels. You can also use scale=1280:-1 to maintain the original aspect ratio automatically.
  • -af "rubberband=tempo=1.5:pitch=1.2": Applies the Rubberband library to the audio. In this example, it speeds up the audio tempo by 1.5x and increases the pitch by a factor of 1.2.
  • output.mp4: The name of the resulting output file.

Method 2: Using -filter_complex

For more advanced processing, or when managing multiple inputs and outputs, use the -filter_complex flag. This allows you to define explicit stream links and process both video and audio in a single unified filtergraph.

Command Example

ffmpeg -i input.mp4 -filter_complex "[0:v]scale=1280:720[v_scaled];[0:a]rubberband=tempo=1.2:pitch=1.0[a_adjusted]" -map "[v_scaled]" -map "[a_adjusted]" output.mp4

Parameter Breakdown

  • [0:v]scale=1280:720[v_scaled]: Takes the video stream of the first input (0:v), scales it, and labels the output stream as [v_scaled].
  • [0:a]rubberband=tempo=1.2:pitch=1.0[a_adjusted]: Takes the audio stream of the first input (0:a), applies the Rubberband pitch/tempo processing, and labels the output stream as [a_adjusted].
  • -map "[v_scaled]" and -map "[a_adjusted]": Maps the labeled processed streams directly to the output file, ensuring the container uses the filtered tracks instead of the original ones.