How to Add Text to Videos, Even When AI Garbles It

What you need before you start · Pick a route: editor, FFmpeg or the generator itself · Why AI clips garble text, and what the current models give you · Steps 1 to 3: generate a clean plate and inspect it · Steps 4 to 6: add text in CapCut or DaVinci Resolve · Steps 7 and 8: set text size and safe zones · Steps 9 and 10: burn text in with FFmpeg drawtext · Step 11: style titles and lower thirds with an ASS file · Step 12: the working project, a cue-driven text tool · Render settings · Check the result before you publish · Common pitfalls when you add text to videos · Troubleshooting: ten errors and their fixes · Advanced tips for text on AI video · Questions creators ask
To add text to a video, drop a text layer on a track above your clip, type the words, style them, and set the second where they appear and vanish. In CapCut or DaVinci Resolve that takes about two minutes. If you would rather script it, one FFmpeg command burns the same text into the file with no editor open.
AI clips add a catch. Video generators predict pixels, not spelling, so letters on a sign, a mug or a title card can bend, swap or change between frames. That holds even for the newest lines: Kling 4.0, which Kling’s own site lists as its flagship, plus Veo 3.1, Seedance 2.5 and Runway Gen-4.5. The safe workflow is to generate the clip with no text and add every word yourself afterward.
This tutorial covers that workflow in 12 steps: a prompt that keeps the frame clean, two editor routes, three FFmpeg routes, and a small Python tool that turns a list of timed cues into titles, lower thirds and captions on any clip. If all you need is auto captions for a short vertical video, our guide to adding captions to a TikTok video is the shorter path. For everything else, read on.
What you need before you start
You need one video clip, one font file, and either an editor or a command line. The table lists each piece with the version rule and the command that confirms it. Where a version number would be a guess, the table tells you how to read your own instead.
| Piece | Requirement | How to check | Used in |
|---|---|---|---|
| FFmpeg | A current stable release built with libx264, libfreetype and libass | ffmpeg -version | Steps 9 to 12 |
| ffprobe | Ships in the same package as FFmpeg | ffprobe -version | Steps 3 and 12 |
| Python | Not listed | python3 --version | Step 12 |
| Font file | TTF or OTF with a licence that allows video use | Read the licence file in the download | Steps 5 to 12 |
| Source clip | MP4 with H.264 video and AAC audio | Step 3 command | All steps |
| Editor (optional) | CapCut (phone or desktop) or the current free DaVinci Resolve | Open the app and find the Text or Titles panel | Steps 4 to 6 |
Run these four commands first. If the filter line prints nothing, your FFmpeg build lacks text support and Step 9 will fail with a missing filter error, so fix that before anything else. The Windows equivalent of grep is findstr.
ffmpeg -version
ffmpeg -hide_banner -filters | grep -E "drawtext|subtitles| ass "
python3 --version
fc-list | grep -i "dejavu sans"
Pick the font with care. A font that ships free for personal use can still block a monetized YouTube channel, so choose one under the SIL Open Font License or a similar terms page that names video as allowed. DejaVu Sans and Noto Sans both qualify and sit on most Linux machines already. Drop the file you choose into a folder called fonts beside your project, because Step 11 points the renderer there.
One last prerequisite is a plan for the raw clip. Keep an untouched copy of every generator output in a folder named clips and never overwrite it. Text you burn into a file cannot come out again, so the clean plate is your only way to fix a typo next week.
Pick a route: editor, FFmpeg or the generator itself
Five routes put words on a video, and they differ in cost, in how easy the text is to change later, and in how well they handle a batch. For one clip with a few edits, use an editor. For ten clips that share a template, script it. Asking the generator to render the text works for throwaway drafts only.

| Route | Best for | Cost | Text editable later? | Main risk |
|---|---|---|---|---|
| CapCut text layer | Phone or quick desktop edits, auto captions | Depends on plan, see the CapCut pricing page | Yes, until you export | Some fonts and effects sit behind a paid plan |
| DaVinci Resolve Text or Text+ | Precise styling, animated titles, long projects | Free edition available | Yes, in the project file | Steeper learning curve |
| FFmpeg drawtext | One or two simple labels, scripted jobs | $0, open source | No, burned in | Escaping rules for colons, quotes and percent signs |
| FFmpeg with an ASS file | Batches, styled titles, lower thirds, fades | $0, open source | Yes, edit the cue file and re-run | Font name must match the installed family |
| Text inside the AI prompt | Rough drafts only | One generation credit per attempt | No, you re-roll | Misspelled or invented letters |
Browser editors such as VEED sit between the first and second rows. They give you a timeline with a text tool and a free tier, and they publish plan limits on the VEED pricing page. Check export caps and watermark rules there before you build a project you cannot export cleanly.
The route you choose in the next few minutes decides how much rework a client note costs you. If your boss changes a job title after you export, an editor project or a cue file takes ten seconds to fix. A burned-in drawtext command takes the same ten seconds only if you saved the command. A text-in-prompt clip means paying for another generation and hoping the letters come out right this time.
This tutorial teaches the editor route first because most readers will use it, then the two FFmpeg routes because they scale. The project in Step 12 uses the ASS route, and it is the one to copy if you produce more than a handful of clips a month. Everything before Step 9 also works if you never open a terminal, so skip ahead to the editor steps if the command line is not your thing.
Why AI clips garble text, and what the current models give you
Video generators learn motion and texture from footage, not spelling. Letters are thin, high-contrast shapes that must stay identical from frame to frame, and a model that predicts each frame from noise has no rule that says a capital R stays an R. You see the result as a shop sign that reads one word in frame 1 and a different word by frame 40, a title whose last letters melt, or a label with an extra character in the middle.
Clip length keeps growing, so the problem has not gone away. ByteDance Seed describes Seedance 2.5 as a 30-second audio-video model with reference control and editing, and it is the company’s latest full model. A 30-second take has far more frames in which text can break than the 5-second clips of a year ago. For a wider look at what each tool outputs, see our comparison of text to video AI by length, audio and price.
| Model line | Newest model, as of November 28, 2026 | What the maker’s page shows | Text plan |
|---|---|---|---|
| Kling | Kling 4.0 | Listed as the newest flagship on Kling’s own site | Generate with no text, add it in post |
| Google Veo | Veo 3.1 | Google DeepMind calls it its leading video generation model | Generate with no text, add it in post |
| ByteDance Seedance | Seedance 2.5 | 30-second audio-video model, released July 31, 2026 | Generate with no text, add it in post |
| Runway | Runway Gen-4.5 | Named on Runway’s own site and plan pages | Generate with no text, add it in post |
One newer variant matters for readers who build on APIs. Reportedly, BytePlus’s model-release documentation lists Dreamina-Seedance 2.5 Flash as a new model with a November 15, 2026 date in its ID, and ByteDance’s own pricing page shows no separate Flash price. Treat it as a faster sibling of Seedance 2.5, not a new generation. On Google’s side, the official Veo page still names Veo 3.1 as the leading Veo model, and I found no announced successor.
Some tools let you edit a generated clip with a text instruction, and the Seedance 2.5 description above mentions editing. That is useful for fixing a prop or a color. It is a poor way to fix a word, because the edit pass redraws the same fragile letter shapes. Every route that regenerates pixels carries the same risk, while an overlay never touches the generated pixels at all.
What one bad take costs
Re-rolling a clip until the sign reads correctly is the most expensive way to add text. The table uses Runway Dev’s list prices, checked on November 28, 2026, where one credit equals $0.01. Kling 4.0 on Runway Dev carries a temporary 20% discount through November 30, 2026 UTC, and the table shows the regular price. Consumer plans on each maker’s own site price differently, so treat this as an API benchmark.
| Model and resolution | List price per second | One 10-second take | Five takes |
|---|---|---|---|
| Kling 4.0, 720p | $0.157 | $1.57 | Not listed |
| Kling 4.0, 1080p | $0.235 | $2.35 | $11.75 |
| Seedance 2.5, 720p | $0.30 | $3.00 | $15.00 |
| Seedance 2.5, 1080p | $0.68 | $6.80 | $34.00 |
| Seedance 2.5, 4K | $1.10 | $11.00 | $55.00 |
| Any clip plus FFmpeg text | $0 | $0 | $0 |
Veo 3.1 Fast prices on Runway Dev vary with resolution and audio, so check the live pricing page before you budget. The point of the table holds for every model, though. Five takes of a 1080p Seedance 2.5 clip cost $34, and the same shot with text added in post costs the one generation plus a few minutes of your time.
Steps 1 to 3: generate a clean plate and inspect it
Step 1. Write a prompt that leaves room for text. Tell the model where the frame stays empty and tell it to render no letters at all. A generator that is not asked for text will still put signs, labels and logos in the background, so name them as exclusions. Put the empty area where your text will go, usually the lower third or the center.
Slow push-in on a ceramic coffee cup on a wooden table, soft morning
window light, shallow depth of field, steam rising. The lower third of
the frame is an empty dark wooden surface. No text, no letters, no
logos, no signs, no packaging labels, no captions, no watermark.
Negative prompt (if your tool has the field):
text, letters, words, logo, watermark, subtitles, signage
Keep the camera move simple. A slow push-in or a locked shot gives you steady space for text, while a whip pan or a handheld shake drags the empty zone around and makes a static title look pasted on. If you need motion, ask for it in the background and keep the foreground calm.
Step 2. Generate and download at the highest resolution you can afford. Text edges look better when you burn them into a 1080p or larger frame, because the encoder has more pixels to hold a thin stroke. Save the file as clips/cup_kling.mp4 or another name that tells you the model. Do not let the app trim or caption the clip on export. Some tools offer both options in the download menu, and they add work you will undo.
Step 3. Probe the file. You need the width, height, frame rate and duration before you pick a font size or a timecode. Run this command and keep the numbers beside your cue list.
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name,width,height,pix_fmt,r_frame_rate:format=duration \
-of default=nw=1 clips/cup_kling.mp4
For a 10-second 1080p clip at 24 frames per second, the output looks like this. Your numbers will differ, and that is fine as long as the codec is H.264 and the pixel format is yuv420p. A different pixel format, such as a 10-bit one, usually means the generator exported a high-bit-depth or HDR file, and the troubleshooting list explains what to do about it.
codec_name=h264
width=1920
height=1080
pix_fmt=yuv420p
r_frame_rate=24/1
duration=10.041667
Watch the shot once with the sound off. Note the seconds when the subject moves through the lower third, because text laid over a moving hand or a bright highlight needs a box or a thicker outline. Write three timecodes on paper: when the title enters, when the lower third enters, and when the final caption leaves. Those become the cues in Step 12.
Steps 4 to 6: add text in CapCut or DaVinci Resolve
The editor route gives you a live preview, so you see exactly how the text sits on the shot. Both editors use the same idea: a text layer is its own clip on a track above the video, and its length on the timeline is how long it stays on screen.

CapCut on phone or desktop
Step 4. Import the clip and add a text layer. Start a new project, import cup_kling.mp4, and put the playhead at the second where the title should appear. Open the Text tool and choose Add text. A default text clip lands on the timeline above the video. Type your title.
Step 5. Style and time it. Pick the font, size, color and outline in the text panel. Drag the ends of the text clip so it spans from your entry time to your exit time. Add an In animation and an Out animation of about 0.3 seconds, which is the same fade the project script uses later. Keep one font for the whole video. Two fonts look like a mistake, three look like a template pack.
Step 6. Add captions if the clip speaks. CapCut offers auto captions that transcribe the audio and place timed text for you. Run them, then read every line, because auto transcripts misspell names and product terms. Our AI video generators hub covers tools whose clips come with native audio, and those are the clips where auto captions earn their keep. Export at 1080p or higher, and read the CapCut pricing page first if you rely on a feature that may sit behind a paid plan.
DaVinci Resolve (free edition)
Open the Edit page and place the clip on Video 1. In the Effects Library, open Titles and drag Text onto Video 2 above your clip. Click the title, open the Inspector, and set the font, size, color and position under the Video tab. Drag the right edge of the title clip to set its duration.
For fades, keyframe Opacity in the Composite section of the Inspector, or use the fade handles at the corners of the clip. Use Text+ instead of Text when you want animation, because it runs on the Fusion page and gives you per-character controls. When the look is right, go to the Deliver page, pick the H.264 MP4 preset, and check the resolution matches your source before you render.
The editor route ends here for a single clip. The rest of the tutorial moves to code, which pays off once you add a second, third or twentieth clip that needs the same text style. If you stay with an editor, save your styled title as a preset or a template so the next clip starts from the same look.
Steps 7 and 8: set text size and safe zones
Text that looks fine in an editor preview can vanish on a phone, because apps draw buttons, usernames and progress bars over the bottom and top of vertical video. Size and placement rules save you from re-exporting. The numbers below are working rules for a 1080-pixel short side. They come from how the project script scales text and are not platform specifications, so check each platform’s current spec page before you finalize a vertical export.
Step 7. Size by the short side of the frame. Both 1920×1080 and 1080×1920 have a short side of 1080 pixels, so the same font sizes work in both. Scale linearly for 4K. Make titles clearly larger than captions, and test that your captions stay legible on a phone held at arm’s length.
| Element | Font size (1080 short side) | Placement | Time on screen | Style |
|---|---|---|---|---|
| Title | 96 px | Center of frame | 2 to 4 seconds | Bold, 5 px outline |
| Lower third | 54 px | Bottom left, 8% up in landscape | 3 to 5 seconds | Dark semi-opaque box |
| Caption | 50 px | Bottom center | 1.5 to 3 seconds per cue | Bold, outline, no box |
| End text or call to action | 72 px | Center or lower third | 3 to 5 seconds | Bold, outline |
| Corner tag | 36 px | Top corner, inside the margin | Whole clip | Regular weight, reduced opacity |
Step 8. Keep text inside the safe zone. Leave at least 6% of the width as a side margin on every element. In vertical video, lift bottom text to about 20% of the frame height from the bottom edge and keep the top 10% clear. In landscape, 8% from the bottom is enough. Then test it: export a draft, play it on a real phone in the target app, and check that no button covers a letter.
Timing follows reading speed. A one-line title needs at least two seconds. A caption of about 10 words needs roughly three. If a viewer cannot read it twice in the time it stays up, shorten the words or lengthen the cue. These are editorial rules of thumb, and the best test is to read your own text aloud at a normal pace and see whether it fits.
Contrast matters as much as size. Pick one of three treatments and stick to it: a heavy outline for titles over busy footage, a dark semi-opaque box for lower thirds, and a soft shadow for captions over calm shots. AI footage often has glowing highlights and crushed shadows in the same frame, so check the first and last second of every cue, not only the middle.
Steps 9 and 10: burn text in with FFmpeg drawtext
FFmpeg’s drawtext filter draws a string on every frame between two timestamps. It suits one or two labels and is the fastest way to prove your pipeline works. Skip it for styled titles, since the ASS route in the next section handles those far better.
Step 9. Draw one centered title for three seconds. The enable option takes an expression, and between(t,1,4) is true from second 1 to second 4. The two x and y expressions center the box using the text’s own width and height. On Windows, write the font path as C\:/Windows/Fonts/arial.ttf, with a backslash before the colon.
ffmpeg -i clips/cup_kling.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:text='Morning Ritual':fontsize=96:fontcolor=white:borderw=5:[email protected]:x=(w-text_w)/2:y=(h-text_h)/2:enable='between(t,1,4)'" -c:v libx264 -crf 18 -preset medium -pix_fmt yuv420p -c:a copy out/cup_title.mp4
Step 10. Add a fade and a second line. The alpha option accepts an expression too, so you can ramp opacity up and down with nested if calls. This version fades in from second 1 to 1.5, holds until second 3.5, and fades out by second 4. Commas inside the single quotes belong to the expression, so the filter parser leaves them alone. A second drawtext after a comma adds a smaller subtitle under the title. Create title.txt first with one line, Morning Ritual.
ffmpeg -i clips/cup_kling.mp4 -vf "drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf:textfile=title.txt:fontsize=96:fontcolor=white:borderw=5:[email protected]:x=(w-text_w)/2:y=h*0.42:alpha='if(lt(t,1),0,if(lt(t,1.5),(t-1)/0.5,if(lt(t,3.5),1,if(lt(t,4),(4-t)/0.5,0))))',drawtext=fontfile=/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf:text='Single origin, slow pour':fontsize=48:fontcolor=white:x=(w-text_w)/2:y=h*0.42+110:enable='between(t,1.3,3.7)'" -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy out/cup_title_fade.mp4
The first drawtext reads its words from title.txt through the textfile option, and that is the habit worth keeping. A text= string must escape colons, single quotes and percent signs, and one missed backslash produces an error that points nowhere useful. A text file takes any character you type, so a title such as Tom's 5:30 Brew, 100% Fresh needs no escaping at all. Save the file as UTF-8 without a byte order mark.
Drawtext has a ceiling. It has no box padding control worth using, no per-line styles, no easy way to build a lower third with a background that hugs two lines, and the expressions grow unreadable fast. When you reach for a third drawtext in one command, switch routes.
Step 11: style titles and lower thirds with an ASS file
ASS (Advanced SubStation Alpha) is a text format that holds styles and timed lines. FFmpeg renders it through libass, which supports fonts, outlines, boxes, fades and moves. Because the styles live in one file, you restyle a whole video by editing a single line and re-running the render.
An ASS file has three parts. The Script Info block sets the virtual canvas, which must match your video size so font sizes mean pixels. The Styles block defines each look. The Events block lists each line with a start time, an end time and a style name. Colors are written as hexadecimal codes, so &H00FFFFFF is white.
[Script Info]
ScriptType: v4.00+
PlayResX: 1920
PlayResY: 1080
WrapStyle: 0
ScaledBorderAndShadow: yes
[V4+ Styles]
Format: Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, Alignment, MarginL, MarginR, MarginV, Encoding
Style: Title,DejaVu Sans,96,&H00FFFFFF,&H000000FF,&H00000000,&H64000000,-1,0,0,0,100,100,0,0,1,5,2,5,115,115,86,1
Style: Lower,DejaVu Sans,54,&H00FFFFFF,&H000000FF,&H50000000,&H00000000,0,0,0,0,100,100,0,0,3,14,0,1,115,115,86,1
[Events]
Format: Layer, Start, End, Style, Name, MarginL, MarginR, MarginV, Effect, Text
Dialogue: 0,0:00:01.00,0:00:04.00,Title,,0,0,0,,{\fad(400,400)}Morning Ritual
Dialogue: 0,0:00:05.00,0:00:08.50,Lower,,0,0,0,,{\fad(250,250)}Jordan Lee\NProducer, Daybreak Coffee
Three details trip people up. First, BorderStyle 3 draws an opaque box behind the text using the outline color, and Outline then sets the box padding, which is why the Lower style uses 14 and the Title style uses 5. Second, Alignment follows the number pad, so 5 is the middle of the frame, 1 is bottom left and 2 is bottom center. Third, \N inside the text starts a new line, and {\fad(400,400)} fades in and out over 400 milliseconds each.
Save the sample as overlay.ass and render it with the ass filter. Point fontsdir at your fonts folder so libass finds the font you shipped instead of guessing.
ffmpeg -i clips/cup_kling.mp4 -vf "ass=overlay.ass:fontsdir=fonts" -c:v libx264 -crf 18 -preset medium -pix_fmt yuv420p -c:a copy out/cup_styled.mp4
From the Vipid archive: if you want a finished title sequence rather than titles over your own footage, the smoke title sequence theme is built for that job.
Step 12: the working project, a cue-driven text tool
Writing ASS by hand works for one clip. For a batch, a short Python script reads a JSON list of cues, probes the video size, builds the styles to scale, writes the ASS file and calls FFmpeg. The layout is four folders and one script.
project/
addtext.py
clips/ raw generator outputs, never overwritten
cues/ one JSON file per clip
fonts/ the font file you chose
out/ finished videos
Save this as addtext.py. The font sizes are fractions of the short side, so the same script gives correct text on a 1920×1080 clip and a 1080×1920 clip. Vertical videos get a 20% bottom margin automatically. Pass --font with the family name of your font, such as Arial on Windows or macOS.
#!/usr/bin/env python3
"""Burn timed titles, lower thirds and captions into a video."""
import argparse
import json
import subprocess
import sys
from pathlib import Path
STYLES = ("Title", "Lower", "Caption")
FORMAT = ("Name, Fontname, Fontsize, PrimaryColour, SecondaryColour, "
"OutlineColour, BackColour, Bold, Italic, Underline, StrikeOut, "
"ScaleX, ScaleY, Spacing, Angle, BorderStyle, Outline, Shadow, "
"Alignment, MarginL, MarginR, MarginV, Encoding")
WHITE, RED, BLACK = "&H00FFFFFF", "&H000000FF", "&H00000000"
SHADOW, BOX = "&H64000000", "&H50000000"
def probe(path):
cmd = ["ffprobe", "-v", "error", "-select_streams", "v:0",
"-show_entries", "stream=width,height", "-of", "json", str(path)]
out = subprocess.run(cmd, capture_output=True, text=True, check=True)
stream = json.loads(out.stdout)["streams"][0]
return int(stream["width"]), int(stream["height"])
def stamp(seconds):
cs = round(seconds * 100)
h, cs = divmod(cs, 360000)
m, cs = divmod(cs, 6000)
s, cs = divmod(cs, 100)
return "%d:%02d:%02d.%02d" % (h, m, s, cs)
def clean(text):
text = text.replace("\\", "").replace("{", "(").replace("}", ")")
return text.replace("\n", "\\N")
def style(name, font, size, outline_col, back_col, bold,
border_style, outline, shadow, align, side, bottom):
return ("Style: %s,%s,%d,%s,%s,%s,%s,%d,0,0,0,100,100,0,0,%d,%d,%d,%d,"
"%d,%d,%d,1" % (name, font, size, WHITE, RED, outline_col,
back_col, bold, border_style, outline, shadow,
align, side, side, bottom))
def styles(w, h, font):
base = min(w, h)
side = round(w * 0.06)
bottom = round(h * (0.20 if h > w else 0.08))
edge = max(2, round(base * 0.005))
pad = round(base * 0.013)
return [
style("Title", font, round(base * 0.089), BLACK, SHADOW, -1,
1, edge, 2, 5, side, bottom),
style("Lower", font, round(base * 0.05), BOX, BLACK, 0,
3, pad, 0, 1, side, bottom),
style("Caption", font, round(base * 0.046), BLACK, SHADOW, -1,
1, edge, 1, 2, side, bottom),
]
def build_ass(w, h, font, cues):
lines = ["[Script Info]", "ScriptType: v4.00+",
"PlayResX: %d" % w, "PlayResY: %d" % h, "WrapStyle: 0",
"ScaledBorderAndShadow: yes", "", "[V4+ Styles]",
"Format: " + FORMAT] + styles(w, h, font) + [
"", "[Events]",
"Format: Layer, Start, End, Style, Name, MarginL, MarginR, "
"MarginV, Effect, Text"]
for i, cue in enumerate(cues, 1):
name = cue.get("style", "Title")
if name not in STYLES:
sys.exit("cue %d: style must be one of %s" % (i, STYLES))
if cue["end"] <= cue["start"]:
sys.exit("cue %d: end must be later than start" % i)
ms = int(cue.get("fade", 0.3) * 1000)
tag = "{\\fad(%d,%d)}" % (ms, ms)
lines.append("Dialogue: 0,%s,%s,%s,,0,0,0,,%s%s" % (
stamp(cue["start"]), stamp(cue["end"]), name, tag,
clean(cue["text"])))
return "\n".join(lines) + "\n"
def main():
ap = argparse.ArgumentParser(description=__doc__)
ap.add_argument("video")
ap.add_argument("cues")
ap.add_argument("output")
ap.add_argument("--font", default="DejaVu Sans")
ap.add_argument("--crf", type=int, default=18)
args = ap.parse_args()
src, out = Path(args.video).resolve(), Path(args.output).resolve()
cues = json.loads(Path(args.cues).read_text(encoding="utf-8"))
w, h = probe(src)
print("probe: %dx%d" % (w, h))
work = Path.cwd()
(work / "overlay.ass").write_text(
build_ass(w, h, args.font, cues), encoding="utf-8")
print("wrote overlay.ass (%d cues)" % len(cues))
vf = "ass=overlay.ass"
if (work / "fonts").is_dir():
vf += ":fontsdir=fonts"
out.parent.mkdir(parents=True, exist_ok=True)
cmd = ["ffmpeg", "-y", "-hide_banner", "-loglevel", "error",
"-i", str(src), "-vf", vf, "-c:v", "libx264",
"-crf", str(args.crf), "-preset", "medium",
"-pix_fmt", "yuv420p", "-c:a", "copy",
"-movflags", "+faststart", str(out)]
subprocess.run(cmd, check=True, cwd=work)
print("wrote %s" % args.output)
if __name__ == "__main__":
main()
Now write the cue file. Each cue has a style, a start and end in seconds, and the text. A fade value in seconds is optional and defaults to 0.3. Use the JSON newline escape, \n, for two-line lower thirds.
[
{"style": "Title", "start": 0.8, "end": 3.6, "text": "Morning Ritual"},
{"style": "Lower", "start": 4.5, "end": 8.0,
"text": "Jordan Lee\nProducer, Daybreak Coffee"},
{"style": "Caption", "start": 8.2, "end": 10.0,
"text": "Brewed fresh every morning", "fade": 0.2}
]
Run it on one clip, then verify the result with ffprobe. A successful run prints three lines, and the check should show the same size and codec as the source.
python3 addtext.py clips/cup_kling.mp4 cues/cup_kling.json out/cup_kling_text.mp4
probe: 1920x1080
wrote overlay.ass (3 cues)
wrote out/cup_kling_text.mp4
ffprobe -v error -select_streams v:0 -show_entries stream=codec_name,width,height,r_frame_rate -of csv=p=0 out/cup_kling_text.mp4
h264,1920,1080,24/1
To process a folder, loop over the clips. Each clip needs a cue file with the same base name, so a missing file stops that clip and tells you which one. On Windows PowerShell the same loop is a one-line Get-ChildItem call piped into ForEach-Object.
for f in clips/*.mp4; do
n=$(basename "$f" .mp4)
python3 addtext.py "$f" "cues/$n.json" "out/${n}_text.mp4"
done
The script has no dependencies beyond Python and FFmpeg, which keeps it easy to hand to a teammate. It also fails loudly. A bad style name or an end time before a start time exits with a message that names the cue, and FFmpeg errors reach your terminal because the call uses check=True.
Render settings
Match the output to the source. Converting the frame rate or scaling the picture while you add text only adds a second chance to degrade it. The script above keeps resolution and frame rate untouched and copies the audio stream. These settings are the defaults it uses.
| Deliverable | Resolution | Frame rate | Length | Export format |
|---|---|---|---|---|
| Landscape master | 1920×1080 | Same as source, often 24 or 30 | Same as source | MP4, H.264, CRF 18, AAC copied |
| Vertical version | 1080×1920 | Same as source | Same as source | MP4, H.264, CRF 18, +faststart |
| 4K master | 3840×2160 | Same as source | Same as source | MP4, H.264 or HEVC, CRF 18 to 20 |
| Review draft | 1280×720 | Same as source | Same as source | MP4, H.264, CRF 23 |
| Text-free plate (archive) | Generator output | Generator output | Untouched | Original file, never re-encoded |
CRF 18 is a quality target for x264, and lower numbers mean larger files and less loss. For text-heavy video, do not go above 23, because high CRF values smear thin strokes first. The +faststart flag moves the index to the start of the file so a browser or social app can begin playback before the full download finishes.
If you ship 4K, keep in mind that Kling reportedly added 4K and HDR output to the Kling 4.0 API on November 19, 2026. Keep your archive plate in whatever the generator produced and only create the delivery copy with text. If you need a smaller file for upload, run a second encode from the plate, never from your finished video.
Check the result before you publish
A text pass breaks in quiet ways. A cue lands a second late, a font falls back, or an accent turns into a box. Pull one still frame from the middle of each cue and look at it at full size. That takes under a minute and catches nearly every error that a quick scrub misses.
mkdir -p checks
ffmpeg -ss 2.0 -i out/cup_kling_text.mp4 -frames:v 1 checks/title.png
ffmpeg -ss 6.0 -i out/cup_kling_text.mp4 -frames:v 1 checks/lower.png
ffmpeg -ss 9.0 -i out/cup_kling_text.mp4 -frames:v 1 checks/caption.png
Use this short checklist on each still and then on a full playback.
- Every word is spelled the way your script spells it, including names and numbers.
- No letter sits near a frame edge, and none sits under where an app will draw its buttons.
- The text reads against the brightest and darkest moment of its cue.
- Fades start and end inside the cue, so nothing pops in or out.
- Audio plays at the same level as the source, with no gap at the start.
- The file size looks right for the length, since a 10-second 1080p clip at CRF 18 should be a few megabytes, not hundreds.
Then play the video on the device your audience uses most. For a Shorts or Reels clip that means a phone. For a YouTube upload that means a laptop and a TV if you can reach one. Fix anything you squint at, and render again from the clean plate.
Common pitfalls when you add text to videos
These seven mistakes account for most re-exports. None needs special skill to avoid, just a habit of checking before you hit render.
- Trusting text the generator drew. Even when the first frame looks right, check the last frame. Letters often drift late in the clip. If a sign must appear, replace it with an overlay instead of hoping.
- Burning text into your only copy. Always render to a new file in
out/and keep the clean plate. A typo found after publishing costs a full re-render if the original is gone. - Ignoring platform interface zones. Vertical apps cover the bottom and the right edge with buttons and captions. Test a draft in the real app, not only in your editor preview.
- Low contrast on moving footage. White text over a bright window vanishes for half a second. Add a clear outline or a semi-opaque box behind the text.
- Cues that vanish too fast. A title that flashes for one second fails the read-it-twice test. Count the words, allow about 0.3 seconds per word, and never go under two seconds for a title.
- Unlicensed fonts. A font you found on a free download site may not allow commercial video. Choose from open-licence families and keep the licence file in the project folder.
- Letting a font fall back silently. When libass cannot find the family you named, it substitutes something else and says nothing. Point
fontsdirat a folder and confirm the render uses the face you picked.
One more habit prevents a whole class of problems. Name files by purpose and version, for example cup_kling_v2_text.mp4, so you never upload the review draft by mistake. Your future self will thank you at 11 pm on deadline day.
Troubleshooting: ten errors and their fixes
Each item lists the symptom, the likely cause and the fix. Work down the list in order, because the first few cover the failures people hit most.
- No such filter: drawtext. Your FFmpeg build lacks libfreetype. Install a full build from your package manager or the project’s download page, then rerun the filter check from the prerequisites section.
- Cannot open font file, or Error initializing filter. The path is wrong or the colon is unescaped on Windows. Use
C\:/Windows/Fonts/arial.ttf, with forward slashes and a backslash before the drive colon. - Text shows as empty boxes. The font has no glyphs for those characters. Switch to a font that covers your script, such as a broad Latin, Cyrillic and Greek face, or a CJK face for Chinese, Japanese and Korean text.
- The ass filter renders nothing. Check that the build includes libass, that the cue times fall inside the clip duration, and that the Script Info size matches the video. A cue that starts after the last frame never draws.
- The wrong font appears in the ASS render. The Fontname field wants the family name, not the file name. Run
fc-list | grep -i nameto read the family, and copy it exactly, including spaces. - Burned SRT captions look tiny. When SRT captions are burned in, a small
FontSizevalue can render far smaller than expected on a 1080p frame. Convert the SRT to ASS, or raiseFontSizeuntil it reads well. - Percent signs disappear from drawtext. The filter treats
%{as an expansion. Escape a literal percent as\%, or move the text into atextfile. - Colors look washed out after export. You probably fed an HDR or 10-bit clip through an 8-bit SDR encode. Export an SDR version from the generator, or tone-map before adding text.
- Audio is missing or the file will not play. The source audio codec does not fit the MP4 container with
-c:a copy. Re-encode it with-c:a aac -b:a 192k. - Text appears at the wrong second. The clip has a non-zero start time. Add
setpts=PTS-STARTPTSat the front of the filter chain, or remux the clip once so its timestamps begin at zero.
If none of those fits, rerun the command without -loglevel error and read the first red line of output. FFmpeg’s complaint nearly always names the option or the file it could not parse.
Advanced tips for text on AI video
Overlay a PNG instead of rendering text. Design the title in any image tool with a transparent background and let FFmpeg place it. This gives you exact typography, including logos and brand lockups, and it avoids font problems on the render machine. Export the PNG at the video’s width for a pixel-sharp match.
ffmpeg -i clips/cup_kling.mp4 -i brand_title.png -filter_complex "[0:v][1:v]overlay=(W-w)/2:H-h-120:enable='between(t,1,4)'" -c:v libx264 -crf 18 -pix_fmt yuv420p -c:a copy out/cup_png.mp4
Move text with ASS. The \move(x1,y1,x2,y2,t1,t2) tag slides a line across the frame, with times in milliseconds. A lower third that slides in over 300 milliseconds looks more finished than a cut. Add it ahead of the fade tag, inside the same braces.
Stitch several AI clips first, then add text once. Most generators cap a clip at a few seconds up to about 30, so a finished video is usually several takes joined together. Join them into one file with matching resolution and frame rate, then run the text tool on the joined file. Cue times then run against one continuous timeline and you write them once.
Generate captions from audio, then restyle them. Several current models output native audio. Transcribe the audio with a speech tool, save the result as SRT, and convert it with ffmpeg -i captions.srt captions.ass. Open the ASS file and replace the default style with your Caption style, then burn it in with the same ass filter. You get the transcript’s timing and your own brand look.
Keep one cue file per language. Because the cue file is plain JSON, a translated version is a copy with new text and the same timing. Check line length after translation, since German and Finnish strings often run noticeably longer than English ones and may wrap outside the safe zone.
Version the project. Put cues/ and addtext.py under git and leave clips/ and out/ out of it. A client who wants last month’s lower third back gets it from a commit, not from memory.
Questions creators ask
What is the easiest way to add text to a video? Open a free editor such as CapCut, import the clip, add a text layer, type, and drag the layer’s ends to set when it shows. Export at the clip’s original resolution. If you do this weekly, move to the FFmpeg and cue-file route in Step 12.
Can I add text to an AI-generated video? Yes, and it is the better method. AI clips are ordinary video files, so any editor or FFmpeg treats them like camera footage. Generate the shot with no text in the prompt and add every word afterward, so the spelling is yours.
Why does text in my AI video look garbled? The model predicts pixels frame by frame and does not know spelling, so thin letter shapes drift. Longer clips drift more. Kling 4.0, Veo 3.1 and Seedance 2.5 are the current lines at their makers, and the safe workflow still keeps text out of the prompt.
Does adding text lower video quality? Burning text means one re-encode, so you lose a little. At CRF 18 with H.264 the loss is hard to see on most footage. Avoid stacking exports. Always encode from the untouched plate, never from a previous export.
What font size should I use for video text? As a working rule, make titles clearly larger than captions and lower thirds, and size everything so it stays readable on a small phone screen. Test on a phone before you publish.
Can I edit the text after I export? Not from the exported file, because burned-in text is part of the picture. Keep the cue file or the editor project and re-render from the clean plate. This is the main reason to archive the raw clip.
Is FFmpeg free for commercial work? FFmpeg is open source and free to run, and its licence terms depend on how your build was compiled. Read the licence notes that ship with your build if you plan to redistribute it inside a product. Using it to process your own videos adds no cost.
More from the Vipid blog
- How to Make a Reel: Phone, Desktop and AI Routes
- Example Subtitle Files You Can Copy: SRT, VTT and ASS
- Vipid intro maker template-based intros, no prompt needed
- Logo Design animated logo intro from your logo file
- Promo product promo theme
- Sample videos finished Vipid intros
Lena Marsh
Lena Marsh is the AI Video Editor at Vipid, covering AI video generators and the platform and software news that changes how creators render, upload and stream. She judges every model by its output — clip length, resolution, frame rate, watermark and cost — rather than by announcements, and runs Vipid’s news radar across the official YouTube, Apple, Adobe, Blackmagic, OBS, OpenAI and Google sources.


