C.W.K.
Stream
Lesson 06 of 10 · published

Text Overlay (drawtext)

~12 min · drawtext, subtitles, lower-third

Level 0Viewer
0 XP0/73 lessons0/15 achievements
0/100 XP to next level100 XP to go0% complete

The most fiddly filter, the most used filter

drawtext burns text into the video. Mandatory parameters: text (or textfile), x, y, fontsize, fontcolor, fontfile. The fontfile is the trickiest — FFmpeg doesn't have system font lookup; you point it at the actual TTF/OTF.

Patterns you'll reuse

  • Lower-third title — large text, white, with a black box behind it for legibility.
  • Timecode burn-in%{pts:hms} expression draws current playback time.
  • Frame counter%{frame_num}.
  • Time-windowed textenable='between(t,2,5)'.

Font path on macOS

Common path: /System/Library/Fonts/Helvetica.ttc or /System/Library/Fonts/Supplemental/Arial.ttf. Or use a specific Homebrew font from /opt/homebrew/share/fonts/.

Code

drawtext recipes·bash
# Simple white text top-left
ffmpeg -i in.mp4 -vf \
  "drawtext=fontfile=/System/Library/Fonts/Supplemental/Arial.ttf:text='Hello':fontcolor=white:fontsize=48:x=20:y=20" \
  -c:a copy out.mp4

# Lower-third with background box
ffmpeg -i in.mp4 -vf \
  "drawtext=fontfile=/System/Library/Fonts/Supplemental/Arial.ttf:text='Pippa Choi':fontcolor=white:fontsize=64:x=80:y=H-160:box=1:boxcolor=black@0.6:boxborderw=20" \
  -c:a copy lower_third.mp4

# Timecode burn-in
ffmpeg -i in.mp4 -vf \
  "drawtext=fontfile=/System/Library/Fonts/Supplemental/Arial.ttf:text='%{pts\\:hms}':fontcolor=yellow:fontsize=32:x=W-tw-20:y=H-th-20:box=1:boxcolor=black@0.5:boxborderw=10" \
  -c:a copy timecode.mp4
Multi-line text from a file·bash
# Put the text in a file (avoids shell-escape hell)
cat > caption.txt <<'EOF'
Line one
Line two
Line three
EOF

ffmpeg -i in.mp4 -vf \
  "drawtext=fontfile=/System/Library/Fonts/Supplemental/Arial.ttf:textfile=caption.txt:fontcolor=white:fontsize=48:x=20:y=20:line_spacing=10" \
  -c:a copy multiline.mp4

External links

Exercise

Add three text overlays to a 30-second clip: (a) a title appearing in the first 5 seconds, lower-thirds style with a black box. (b) A burnt-in timecode in the bottom-right for the whole clip. (c) A small 'pippa.dev' watermark in the top-left, semi-transparent. Use textfile for any apostrophes.

Progress

Progress is local-only — sign in to sync across devices.
Spotted a bug or have feedback on this page?Report an Issue

Comments 0

🔔 Reply notifications (sign in)
Sign inPlease sign in to comment.

No comments yet — be the first.