Create Rolling Credits with FFmpeg Drawtext Filter

Creating a professional rolling credits sequence doesn’t require complex video editing software; you can achieve it directly from the command line using FFmpeg. This guide demonstrates how to use the drawtext filter to animate text vertically across the screen, covering the essential syntax, math formulas for the scroll effect, and practical examples for customizing your end credits.

The Core Concept of Scrolling Text

To make text scroll vertically in FFmpeg, you must animate its vertical position (y) relative to time (t). In FFmpeg’s drawtext filter, the variable H represents the height of the video frame, and t represents the current time of the video in seconds.

By setting the vertical coordinate formula to y=H-t*speed, the text starts at the very bottom of the screen (where y equals the video height H) at \(t=0\), and moves upward by a set number of pixels per second as time progresses.

Step 1: Prepare Your Credits Text

Create a plain text file named credits.txt containing the text you want to scroll. For example:

THE END

Directed by
John Doe

Produced by
Jane Smith

Lead Actor
Alex Jones

Thank you for watching!

Step 2: The Basic Rolling Credits Command

Run the following command in your terminal. This command generates a blank 10-second black video at 1080p resolution and scrolls the text from credits.txt upward.

ffmpeg -f lavfi -i color=c=black:s=1920x1080:d=10 -vf "drawtext=fontfile='C\:/Windows/Fonts/arial.ttf':textfile='credits.txt':fontcolor=white:fontsize=48:x=(w-tw)/2:y=H-150*t" -c:a copy output.mp4

(Note: Windows users should format the font path with escaped colons as shown above. Mac users can use fontfile='/Library/Fonts/Arial.ttf', and Linux users can use /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf.)

Step 3: Understanding the Parameters

Fine-Tuning Your Credits

Adjusting Speed and Duration

The total height of your text layout must be cleared by the end of the video. If your text is long, it might cut off before finishing if the video duration is too short, or it might scroll too fast to read.

To find the perfect balance: * To slow down the scroll: Decrease the speed multiplier (e.g., change 150*t to 80*t) and increase the input duration (d=20). * To speed up the scroll: Increase the speed multiplier (e.g., 250*t).

Overlaying Credits on an Existing Video

If you want to roll credits over a pre-existing background video instead of a solid black screen, replace the synthetic color input with your video file:

ffmpeg -i background.mp4 -vf "drawtext=fontfile='arial.ttf':textfile='credits.txt':fontcolor=white:fontsize=48:x=(w-tw)/2:y=H-120*t" -c:a copy output.mp4