FFmpeg: Overlay Scrolling Text on Blurred Background Video
This article explains how to use FFmpeg to create a professional video layout featuring a blurred background of your video, a centered sharp version of the same video on top, and a scrolling text box overlay. You will learn the exact FFmpeg command required to achieve this effect, along with a detailed breakdown of how the filtergraph processes the video and text layers.
The Complete FFmpeg Command
To create a blurred background from your input video, overlay the sharp original video in the center, and add a horizontally scrolling text box at the bottom, run the following command:
ffmpeg -i input.mp4 -filter_complex \
"[0:v]split=2[bg][fg]; \
[bg]scale=1920:1080:force_original_aspect_ratio=increase,crop=1920:1080,boxblur=20:5[bg_blur]; \
[fg]scale=-1:1080[fg_scale]; \
[bg_blur][fg_scale]overlay=(W-w)/2:(H-h)/2[base]; \
[base]drawtext=text='Your scrolling announcement text goes here...':x=w-t*150:y=h-150:fontsize=36:fontcolor=white:box=1:boxcolor=black@0.6:boxborderw=20[outv]" \
-map "[outv]" -map 0:a? -c:a copy output.mp4How the Command Works
The command utilizes FFmpeg’s -filter_complex flag to
chain several video filters together in a single pass:
- Splitting the Input (
split):[0:v]split=2[bg][fg]duplicates the input video stream into two identical streams, namedbg(background) andfg(foreground). - Creating the Blurred Background (
scale,crop,boxblur):scale=1920:1080:force_original_aspect_ratio=increasescales the background stream to fill a 1920x1080 canvas.crop=1920:1080cuts off any excess video to ensure a perfect 16:9 ratio.boxblur=20:5applies a heavy blur effect to this background layer.
- Scaling the Foreground (
scale):scale=-1:1080scales the second video stream to a height of 1080 pixels while preserving its original aspect ratio. - Overlaying the Streams (
overlay):overlay=(W-w)/2:(H-h)/2places the sharp foreground video directly in the center of the blurred background video. - Adding the Scrolling Text Box
(
drawtext):text='...': Specifies the scrolling message.x=w-t*150: Animates the text horizontally. It starts at the right edge of the screen (w) and moves left at a speed of 150 pixels per second multiplied by the timestamp (t).y=h-150: Positions the text box 150 pixels from the bottom of the video frame.box=1:boxcolor=black@0.6:boxborderw=20: Creates a solid black background box behind the text with 60% opacity (0.6) and 20 pixels of padding (boxborderw) to act as the text box container.
Customization Tips
- Adjust Speed: To make the text scroll faster,
increase the multiplier in the expression (e.g.,
t*250). To slow it down, decrease it (e.g.,t*100). - Vertical Scroll: To scroll the text vertically
instead of horizontally, change the coordinates to
x=(w-tw)/2(to center it horizontally) andy=h-t*50(to scroll up from the bottom). - Font and Size: You can specify a custom font file
by adding the
fontfile=/path/to/font.ttfparameter inside thedrawtextfilter.