AI Video Editing Flows

FFmpeg overlay text and images: drawtext, logo and picture in picture

FFmpeg can draw text on a backing box, place a PNG, and put one video inside another. On our test file the logo overlay changed the pixel at its position from RGB (0, 255, 255) to (253, 0, 0), and the picture in picture matched the small clip within one level. Text on Windows needs a font file: without one our command crashed.

What to choose

JobFilterWhere
Text with a backing boxdrawtext with box=1Needs fontfile on Windows
Logo or imageoverlay with a second inputx and y from W, H, w, h
Video inside videoscale then overlaySame overlay filter

All three keep the sound with -c:a copy, so only the picture is re-encoded.

Text with a backing box

drawtext reads a font file. box=1 draws a box behind the text, boxcolor sets its colour and transparency, and boxborderw adds padding. y=h-120 puts the top of the text 120 pixels above the bottom.

Text on a semi-transparent black box
ffmpeg -i a.mp4 -vf "drawtext=fontfile='C\:/Windows/Fonts/arial.ttf':text='Hello from FFmpeg':fontsize=48:fontcolor=white:box=1:boxcolor=black@0.7:boxborderw=20:x=60:y=h-120" -c:a copy dt.mp4

We checked it by sampling a 12x12 patch inside the box, left of the text, at 3 s. In the source it averaged RGB (253, 0, 0) and in the output (76, 0, 0), so the box darkened it. A patch far from the box went from (247.5, 16.3, 68.6) to (247.3, 17.1, 69.6).

Without fontfile our drawtext command did not finish. FFmpeg printed "Fontconfig error: Cannot load default config file: File not found" and exited with code 0xC0000005, and no output file was written.

This crashed on our Windows build: no fontfile
ffmpeg -i a.mp4 -vf "drawtext=text='Hello':fontsize=48:fontcolor=white" -c:a copy dt_nofont.mp4

In a Windows path inside a filter, write the drive colon as C\: and use forward slashes, as in the command above.

Logo overlay

We made a 120x120 red PNG to stand in for a logo. overlay=W-w-20:20 puts it 20 pixels from the right edge and 20 from the top. W and w are the main and overlay widths.

Make a stand-in logo, logo.png
ffmpeg -f lavfi -i "color=c=red:s=120x120,format=rgba" -frames:v 1 logo.png
Overlay at the top right
ffmpeg -i a.mp4 -i logo.png -filter_complex "overlay=W-w-20:20" -c:a copy logo.mp4

At the logo centre, an 8x8 patch at 3 s averaged RGB (0, 255, 255) in the source and (253, 0, 0) in the output.

Show an overlay for a few seconds

enable limits the overlay to a time range. The same patch measured RGB (0, 255, 255) at 1 s, (253, 0, 0) at 3 s and (0, 255, 255) at 7 s.

Logo visible from 2 s to 6 s
ffmpeg -i a.mp4 -i logo.png -filter_complex "overlay=W-w-20:20:enable='between(t,2,6)'" -c:a copy logo_timed.mp4

Picture in picture

Scale the second video first, then overlay it in a corner. Our second input was a 10 s SMPTE colour bars clip.

Make bars.mp4
ffmpeg -f lavfi -i smptebars=duration=10:size=640x360:rate=30 -c:v libx264 -pix_fmt yuv420p bars.mp4
320 wide picture in the bottom right
ffmpeg -i a.mp4 -i bars.mp4 -filter_complex "[1:v]scale=320:-2[pip];[0:v][pip]overlay=W-w-20:H-h-20" -c:a copy pip.mp4

An 8x8 patch inside the small picture averaged RGB (190, 190, 190) in the output. The same patch of the scaled bars clip alone was (189, 189, 189). The source video there was (123.5, 127, 191.2).

Check the result

We extracted one frame, cropped a small patch and averaged its colour, for the source and the output at the same position. This command writes the patch for the logo check:

Write an 8x8 patch of the output at 3 s; it averaged RGB (253, 0, 0)
ffmpeg -ss 3 -i logo.mp4 -frames:v 1 -update 1 -vf crop=8:8:1196:76 patch_logo.png

A changed patch only proves the overlay is there. Play the file to check position, timing and that text is readable.

Method and limits

All commands ran on FFmpeg 8.1.2 (a full Windows build) on a Windows 11 laptop, Ryzen 7 7735U, CPU only, on 2026-11-06. We added -y and -threads 4 to every run; they are left out of the commands shown. In quoted FFmpeg messages the hex address after @ changes on every run, so we replaced it with ...

a.mp4 is a synthetic 10 s test file (testsrc2 picture and a sine tone, 1280x720, 30 fps, a keyframe every 2 seconds), made with the command below. The logo and the picture in picture came from generated files, shown above.

Make a.mp4
ffmpeg -f lavfi -i testsrc2=duration=10:size=1280x720:rate=30 -f lavfi -i sine=frequency=440:duration=10:sample_rate=48000 -c:v libx264 -pix_fmt yuv420p -g 60 -keyint_min 60 -sc_threshold 0 -c:a aac -shortest a.mp4

Limits: one run of each command, so the sizes and times are single measurements and not averages. Times were taken on a laptop that was doing other work. Results depend on the input file and the FFmpeg version, so check yours. We did not test other fonts, text effects, alpha logos or non-Windows font paths.

Related: FFmpeg for video editors, FFmpeg resize and crop video: scale, pad and 9:16, FFmpeg extract frames and turn images into video, Join videos with FFmpeg without errors and FFmpeg command builder.

Page checked on Nov 4, 2026.