Scroll Text Vertically Like Movie Credits in FFmpeg
This guide explains how to create a vertical scrolling text effect,
similar to movie credits, using the FFmpeg drawtext filter.
You will learn the exact command-line syntax, how to control the
scrolling speed, and how to position your text so it rolls smoothly from
the bottom to the top of your video.
To create a scrolling credits effect, you must dynamically change the
vertical coordinate (y) of the text over time. FFmpeg
allows you to do this by using the t (time in seconds)
variable inside the drawtext filter expression.
Here is the standard command to scroll a text file over a solid black background:
ffmpeg -f lavfi -i color=c=black:s=1920x1080:d=20 -vf "drawtext=fontfile=sans.ttf:textfile=credits.txt:fontsize=48:fontcolor=white:x=(w-tw)/2:y=h-t*150" -c:v libx264 -pix_fmt yuv420p output.mp4How the Command Works
-f lavfi -i color=c=black:s=1920x1080:d=20: This generates a synthetic 1920x1080 black background video that lasts for 20 seconds. If you want to overlay credits on an existing video, replace this part with-i your_video.mp4.fontfile=sans.ttf: The path to your desired TrueType (.ttf) or OpenType (.otf) font. You must provide a valid path to a font file on your system.textfile=credits.txt: A plain text file containing your credits. Using a text file is highly recommended for multi-line credits because it preserves line breaks.x=(w-tw)/2: This centers the text horizontally.wis the width of the video, andtw(ortext_w) is the width of the rendered text.y=h-t*150: This is the formula that drives the vertical scroll.his the height of the video frame.tis the current playback time in seconds.150is the scroll speed in pixels per second. Att=0, the text starts aty=h(just off the bottom of the screen) and moves upward by 150 pixels every second.
Adjusting the Scroll Speed
To change how fast the credits scroll, modify the multiplier in the
y equation. * Slower scroll: Decrease the
number (e.g., y=h-t*100). * Faster scroll:
Increase the number (e.g., y=h-t*250).
Overlaying Credits on an Existing Video
If you want to overlay the scrolling credits on top of an existing video instead of a black background, use this command:
ffmpeg -i input.mp4 -vf "drawtext=fontfile=sans.ttf:textfile=credits.txt:fontsize=48:fontcolor=white:x=(w-tw)/2:y=h-t*150" -c:a copy output.mp4This command applies the filter directly to input.mp4
and copies the audio stream without re-encoding it, saving processing
time.