How to Use the FFmpeg Scroll Filter
This article provides a quick guide on how to use the
scroll video filter in FFmpeg to create continuous
horizontal or vertical scrolling effects. You will learn the basic
syntax of the filter, understand its primary parameters, and see
practical command-line examples for scrolling videos and images.
The scroll filter in FFmpeg allows you to shift video
frames horizontally or vertically, wrapping the edges around so the
content repeats in a continuous loop. This is highly useful for creating
moving backgrounds, ticker tapes, or panoramic transitions.
Basic Syntax
The basic syntax for the scroll filter is:
-vf "scroll=horizontal=h_speed:vertical=v_speed"Parameters
horizontal(orh): Sets the horizontal scrolling speed.- A positive value (e.g.,
0.005) scrolls the video to the right. - A negative value (e.g.,
-0.005) scrolls the video to the left. - The value represents the fraction of the frame width to shift per
frame (ranging from
-1.0to1.0).
- A positive value (e.g.,
vertical(orv): Sets the vertical scrolling speed.- A positive value scrolls the video downward.
- A negative value scrolls the video upward.
- The value represents the fraction of the frame height to shift per
frame (ranging from
-1.0to1.0).
Practical Examples
1. Scroll Horizontally (Left to Right)
To scroll a video or image continuously from left to right, set a positive horizontal speed.
ffmpeg -i input.mp4 -vf "scroll=horizontal=0.005" -c:a copy output.mp42. Scroll Vertically (Bottom to Top)
To create an upward scrolling effect (similar to movie credits), set a negative vertical speed.
ffmpeg -i input.mp4 -vf "scroll=vertical=-0.003" -c:a copy output.mp43. Scroll Diagonally
You can combine both horizontal and vertical parameters to scroll the video diagonally.
ffmpeg -i input.mp4 -vf "scroll=horizontal=0.002:vertical=0.002" -c:a copy output.mp44. Scrolling a Static Image to Create a Video
If you want to turn a static, seamless panoramic image into a 10-second scrolling video, you must first define the frame rate and duration, then apply the scroll filter:
ffmpeg -loop 1 -i input.png -vf "scroll=horizontal=0.002,format=yuv420p" -t 10 output.mp4Note: The format=yuv420p filter is added after the
scroll filter to ensure maximum compatibility with standard media
players.