Use drawtext with fontsize=h/14 for a title that scales with the frame, and escape every colon in the text or ffmpeg stops with exit code 234. ReelSDK runs it at $0.02 per compute minute, Anton and other fonts included.
How can I add text to a video with ffmpeg?
To add text to a video, run ffmpeg's drawtext filter and size it from the frame: h/14 for a title, h/30 for a clock. On ReelSDK the fonts in /usr/share/fonts/reelsdk work as they are, and any other font comes in as an input URL.
GuidesUpdated
ffmpeg -i in.mp4 -vf "drawtext=fontfile=Poppins-Bold.ttf:text='Seville, day 1':\
fontsize=h/14:fontcolor=white:box=1:boxcolor=black@0.55:boxborderw=28:\
x=(w-text_w)/2:y=h*0.08:enable='between(t,0.5,6)',\
drawtext=fontfile=Poppins-Bold.ttf:text='%{pts\:hms}':fontsize=h/30:\
fontcolor=white:box=1:boxcolor=black@0.55:boxborderw=14:\
x=w-text_w-40:y=h-text_h-40" -c:v libx264 -crf 20 -c:a copy titled.mp4The title sits centered near the top on a half-transparent box from 0.5 to 6 s; the clock runs in the bottom-right corner the whole time.
Variations
The other commands you will need
A colon in the text
The colon separates options, so escape it inside the text. Without the backslash ffmpeg stopped with exit code 234.
escape ffmpeg -i in.mp4 -vf "drawtext=fontfile=Poppins-Bold.ttf:text='Seville\: day 1':fontsize=72" \ -frames:v 1 escaped.pngYour own font
Any .ttf or .otf file works; give the path. Here, Anton for a 2-second clip.
own font ffmpeg -i in.mp4 -t 2 -vf "drawtext=fontfile=Anton-Regular.ttf:text='Seville':\ fontsize=h/8:fontcolor=white:x=(w-text_w)/2:y=h*0.1" -c:v libx264 -crf 23 -an font.mp4
The flags
The options in these commands
| Flag | What it does | Used here |
|---|---|---|
fontfile= | Path to the font file | All |
text='...' | The text; escape : and ' inside it | All |
fontsize=h/14 | Size in pixels; an expression of the frame height keeps it in proportion. The default is 16 | Title |
box=1, boxcolor=black@0.55 | A box behind the text, 55% opaque black | Title, clock |
boxborderw=28 | Padding between the text and the edge of the box | Title |
x=(w-text_w)/2 | Centers the text: frame width minus text width, halved | Title |
y=h*0.08 | 8% down from the top | Title |
enable='between(t,0.5,6)' | Draws only from 0.5 s to 6 s | Title |
%{pts\:hms} | Prints the frame time as HH:MM:SS.mmm | Clock |
x=w-text_w-40:y=h-text_h-40 | 40 px in from the bottom-right corner | Clock |
Sources: ffmpeg filters: drawtext, ffmpeg filters: timeline editing, checked November 2026.
Why the colon breaks it
A filter's options are separated by colons, and the filter graph has its own quoting on top. The single quotes around the text are used up by the first layer, so text='Seville: day 1' still reaches drawtext as two options. ffmpeg stopped with "No option name near ' day 1:fontsize=72'" and exit code 234.
Put a backslash before the colon inside the text: text='Seville\: day 1'. The same goes for the clock: %{pts\:hms} needs it because pts:hms has a colon too. In a shell, the outer double quotes keep the backslash intact.
Sizes that follow the frame
drawtext sizes are in pixels, and the default is 16, which is tiny on HD video. Use the frame height instead: fontsize=h/14 is about 77 px at 1080 px tall and scales by itself on other sizes. Positions work the same way: text_w and text_h are the size of the rendered text, w and h the frame, so x=(w-text_w)/2 always centers.
Show it only for a while
enable turns a filter on and off by time. between(t,0.5,6) draws the title from half a second to six seconds and leaves the rest of the clip alone. Each drawtext in the chain has its own enable, so you can stack several titles with different timings in one command.
Fonts on a server
fontfile needs a real path; there is no default you can count on. On the API, Anton, Bebas Neue, Montserrat Black and ExtraBold, Poppins Bold, ExtraBold and Black, and Noto Sans JP, SC, KR, Arabic, Hebrew, Thai, Devanagari, Lao and Myanmar in Bold are installed under /usr/share/fonts/reelsdk. For anything else, list the font's URL in inputs and refer to it by its file name: our Anton test did exactly that and finished in about 5 seconds.
For captions that follow speech, drawtext is the wrong tool. Write an SRT and burn it with the subtitles filter, or let POST /v1/captions transcribe and style it.
Without installing ffmpeg
The same command as one API call
Send the same args to POST /v1/ffmpeg. The fonts we bundle sit in /usr/share/fonts/reelsdk; for any other font, put its URL in inputs and use the file name, as we did with Anton. Each job runs ffmpeg 8.1 on a fresh machine at $0.02 per compute minute, billed per second; this one finished in about 11 seconds and cost under half a cent.
curl "https://api.reelsdk.com/v1/ffmpeg?wait=60" \
-H "Authorization: Bearer $REELSDK_KEY" \
--json '{
"inputs": {
"in.mp4": "https://api.reelsdk.com/f/lib/demo/landscape.mp4"
},
"args": [
"-i", "in.mp4", "-vf",
"drawtext=fontfile=/usr/share/fonts/reelsdk/Poppins-Bold.ttf:text='\''Seville, day 1'\'':fontsize=h/14:fontcolor=white:box=1:boxcolor=black@0.55:boxborderw=28:x=(w-text_w)/2:y=h*0.08:enable='\''between(t,0.5,6)'\'',drawtext=fontfile=/usr/share/fonts/reelsdk/Poppins-Bold.ttf:text='\''%{pts\\:hms}'\'':fontsize=h/30:fontcolor=white:box=1:boxcolor=black@0.55:boxborderw=14:x=w-text_w-40:y=h-text_h-40",
"-c:v", "libx264", "-crf", "20", "-c:a", "copy", "titled.mp4"
],
"outputs": ["titled.mp4"]
}'FAQ
Questions, answered
How do I add text to a video with ffmpeg?
Use -vf "drawtext=fontfile=font.ttf:text='Hello':fontsize=h/14:fontcolor=white:x=(w-text_w)/2:y=h*0.08" and re-encode the video, copying the audio.
Why does drawtext fail with No option name near?
The text has a colon or quote that ends the option. Escape it with a backslash, as in text='Seville\: day 1'.
How do I show text only for a few seconds?
Add enable='between(t,0.5,6)' to the drawtext filter; it draws only while t is between the two times in seconds.
Can I add text to video with an API?
Yes. POST the same args to https://api.reelsdk.com/v1/ffmpeg with fontfile pointing at /usr/share/fonts/reelsdk or at a font you list in inputs. It runs ffmpeg 8.1 for $0.02 per compute minute, billed per second.
- Burn subtitles into a video with ffmpegHardcode an SRT into the picture with the subtitles filter and force_style, or add it as a soft track players can switch off.
- Add a watermark or logo to a video with ffmpegPut a PNG logo in a corner with overlay: scale it, make it semi-transparent, keep it off the edge, or show it only for the first seconds.
- Picture-in-picture video with ffmpegPut one video in the corner of another with scale, pad and overlay, end it with the main clip, or bring the inset in later.
- Trim a video with ffmpegCut a clip with -ss and -to: frame-exact with a re-encode, fast with -c copy, and why the copy starts before your time.
- ffmpeg -filter_complex explainedLabels, commas and semicolons: how a filtergraph wires inputs to outputs, with four working graphs and the errors they fix.
- Watermark videoStamp a PNG logo on every frame at any position and opacity with one ffmpeg call, about two thirds of a cent per 30 s clip.
- FFmpeg onlineRun your own ffmpeg command on your files in the browser, free and without installing or uploading anything.
- Auto captions API: word-by-word captions for $0.03 a minuteSend a video URL, get an MP4 with word-by-word captions burned in plus SRT, VTT, ASS and a word-timed transcript. $0.03 per output minute with transcription included; a 30-second clip renders in 30 to 43 seconds.
Sources, checked November 2026
Ready to build?
Ship video from your app today
Your first $0.50 is free, and one key covers every endpoint.
