How to Scroll Video Horizontally and Vertically in FFmpeg

This guide explains how to use the FFmpeg scroll filter to continuously scroll a video either horizontally or vertically. You will learn the basic syntax of the filter, how to control the scroll speed and direction, and see practical command examples for horizontal, vertical, and diagonal scrolling effects.

Understanding the FFmpeg Scroll Filter

The scroll filter in FFmpeg moves the video frame continuously in a specified direction. As the video scrolls off one side of the screen, it automatically wraps around and reappears on the opposite side, creating a seamless loop effect.

The filter accepts two main parameters: * horizontal (or h): Controls the horizontal scroll speed. * vertical (or v): Controls the vertical scroll speed.

The speed values are expressed as a fraction of the frame’s size per frame (ranging from -1.0 to 1.0). For example, a value of 0.01 means the video moves by 1% of its width or height per frame. Positive values scroll the video in one direction, while negative values scroll it in the opposite direction.


Horizontal Scrolling

To scroll a video horizontally, define the horizontal (or h) parameter while keeping the vertical parameter at 0 (which is the default).

Scroll Left to Right

To scroll the video slowly from left to right, use a negative value:

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

Scroll Right to Left

To scroll the video from right to left, use a positive value:

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

Vertical Scrolling

To scroll a video vertically, define the vertical (or v) parameter.

Scroll Upwards

To scroll the video from bottom to top, use a positive vertical value:

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

Scroll Downwards

To scroll the video from top to bottom, use a negative vertical value:

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

Diagonal Scrolling (Combining Both Axes)

You can combine both parameters in a single command to scroll the video diagonally. The following command scrolls the video both horizontally and vertically at the same time:

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

Tips for Best Results