How to Configure Scroll Speed in FFmpeg Scroll Filter

This article explains how to configure both horizontal and vertical scrolling speeds using the FFmpeg scroll video filter. You will learn the specific parameters required to control scroll direction and velocity, along with practical command-line examples to help you apply these effects to your video projects.

The FFmpeg scroll filter allows you to continuously scroll a video horizontally, vertically, or both simultaneously. The speed and direction of the scroll are determined by two main parameters, measured in pixels per frame:

Parameter Values and Direction

The direction of the scroll is controlled by using positive or negative values:

Practical Command Examples

To apply the filter, use the -vf (video filter) flag followed by the scroll filter and your desired parameters.

1. Horizontal Scroll (Left to Right)

To scroll a video horizontally from left to right at a speed of 5 pixels per frame:

ffmpeg -i input.mp4 -vf "scroll=horizontal=5" output.mp4

2. Horizontal Scroll (Right to Left)

To scroll a video horizontally from right to left at a speed of 3 pixels per frame:

ffmpeg -i input.mp4 -vf "scroll=h=-3" output.mp4

3. Vertical Scroll (Top to Bottom)

To scroll a video vertically downward at a speed of 4 pixels per frame:

ffmpeg -i input.mp4 -vf "scroll=vertical=4" output.mp4

4. Simultaneous Horizontal and Vertical Scroll

To scroll a video diagonally (moving right and up simultaneously), combine both parameters using a colon (:):

ffmpeg -i input.mp4 -vf "scroll=h=2:v=-2" output.mp4

Calculating Scroll Speed in Seconds

Because speed is defined in pixels per frame, the actual visual speed depends on your video’s frame rate (FPS). You can calculate the speed in pixels per second using this formula:

\[\text{Pixels per Second} = \text{Speed Value} \times \text{Video FPS}\]

For example, if your video runs at 30 FPS and you set h=5, the video will scroll at a rate of 150 pixels per second (\(5 \times 30\)).