FFmpeg Scroll Filter: How to Continuously Scroll Video
This article explains how to use the FFmpeg scroll
filter to continuously scroll a video horizontally, vertically, or
diagonally. You will learn the core syntax of the filter, how to control
the direction and speed of the scroll, and see practical command-line
examples to apply this effect to your video files.
Understanding the
scroll Filter
The scroll filter in FFmpeg allows you to pan or scroll
a video continuously. When the video scrolls past the edge of the frame,
it wraps around to the opposite side, creating an infinite looping
scroll effect.
The filter uses two main parameters to control the speed and
direction: * horizontal (or
h): Controls horizontal scrolling speed. The value
ranges from -1.0 to 1.0. *
vertical (or v): Controls
vertical scrolling speed. The value ranges from -1.0 to
1.0.
A positive value scrolls the video to the left (or up), while a
negative value scrolls it to the right (or down). A value of
0 disables scrolling in that direction. The closer the
value is to 0 (e.g., 0.005), the slower and
smoother the scroll will be.
Practical Examples
Here are the commands to achieve different scrolling effects.
1. Continuous Horizontal Scroll (Right to Left)
To scroll a video continuously from right to left, use a positive horizontal value.
ffmpeg -i input.mp4 -vf "scroll=h=0.005" -c:a copy output.mp42. Continuous Horizontal Scroll (Left to Right)
To reverse the direction and scroll from left to right, use a negative horizontal value.
ffmpeg -i input.mp4 -vf "scroll=h=-0.005" -c:a copy output.mp43. Continuous Vertical Scroll (Bottom to Top)
To scroll a video vertically from the bottom to the top, apply a positive value to the vertical parameter.
ffmpeg -i input.mp4 -vf "scroll=v=0.005" -c:a copy output.mp44. Continuous Diagonal Scroll
You can combine both horizontal and vertical values to make the video scroll diagonally.
ffmpeg -i input.mp4 -vf "scroll=h=0.003:v=0.003" -c:a copy output.mp4Adjusting the Initial Position
If you want the scroll to start from a specific offset instead of the default top-left corner, you can use the position parameters:
hpos: Horizontal start position (as a fraction of the frame width, from0to1).vpos: Vertical start position (as a fraction of the frame height, from0to1).
For example, to start the video scroll with a 50% horizontal offset:
ffmpeg -i input.mp4 -vf "scroll=h=0.005:hpos=0.5" -c:a copy output.mp4