Rendering Animated Captions with ffmpeg and libass: Transparent Overlays, Emoji, and a Premiere Bug

In my last post I covered how AutoCaptions gets a timestamp for every word. This one is about turning those timestamps into video: burned-in animated captions for the web editor, and transparent caption overlays for a Premiere Pro panel. It all runs on ffmpeg with libass, on a CPU-only server.
Why ASS subtitles
ASS (Advanced SubStation Alpha) is an old anime fansub format, and it's perfect for this. It supports fonts, outlines, shadows, colors, positioning and animation tags, and ffmpeg's ass filter renders it with libass.
The browser editor generates the ASS file, so the preview and the export come from the same caption engine. Each caption chunk becomes several events, one per word state, and the active word gets a different color. A pop-in is one override tag:
{\fscx80\fscy80\t(0,110,\fscx100\fscy100)}
Start at 80% scale and animate to 100% over 110 ms. Styles like Hormozi, Karaoke and Neon are just different combinations of font, outline, colors and these tags.
Burning captions into a video is then a single ffmpeg filter:
ffmpeg -i in.mp4 -vf "ass=subs.ass:fontsdir=fonts" -c:a copy out.mp4
Shipping the fonts with the worker (fontsdir) matters: without it, libass falls back to whatever fonts the server happens to have, and your Montserrat Black quietly becomes something else.
Transparent overlays: libass draws no alpha
For the Premiere Pro panel I didn't want to re-encode the user's footage. Better to render a captions-only video with transparency and drop it on a track above their clip.
The catch: the ass filter draws onto an existing frame. It doesn't give you an alpha channel. The fix is to render twice:
- Draw the captions in color on a black background.
- Draw the same captions all white, as a mask.
- Merge the mask in as alpha.
[0:v]split[a][b];
[a]ass=subs.ass,format=rgba[c];
[b]ass=mask.ass,format=gray[m];
[c][m]alphamerge,unpremultiply=inplace=1
mask.ass is the same file with every color set to white. The unpremultiply step turns the result into straight (non-premultiplied) alpha, which is what the output format expects.
The Premiere streak bug
My first overlay used QuickTime Animation (qtrle), the classic codec for video with alpha. It played fine in every player, and in Premiere it left streaks: old captions smeared across frames.
qtrle stores per-frame deltas, and Premiere decoded them wrongly. Forcing every frame to be a keyframe fixed the streaks but made the files huge.
What worked: PNG-in-MOV. Every frame is an independent PNG, so there's nothing to decode incrementally, and because caption frames are mostly empty, PNG compresses them well. The files came out about 4x smaller than all-keyframe qtrle.
-c:v png -pix_fmt rgba overlay.mov
Color emoji
libass can't draw color emoji, and auto emoji is one of the most popular features. The browser can, though.
So the editor draws each emoji to a PNG and sends it inside the ASS file as Comment: lines with its position and timing. Comment lines are ignored by every subtitle renderer, so the file stays valid ASS. The worker reads them, validates and saves the PNGs, and adds one ffmpeg overlay filter per emoji, enabled only between its start and end time.
Performance
On the ARM server, a 1080p burn runs at roughly 3x realtime. The worker allows two jobs at once and keeps long videos in a single lane, so a long render can't starve short ones.
Takeaways
- ASS + libass is underrated for anything text-on-video. One format covers styling and animation.
- Generate the subtitle file where the preview lives so what you see is what you export.
- Test overlays in the actual NLE. qtrle looked perfect everywhere except the one app that mattered.
- Smuggle what the format can't do (emoji PNGs) in comment lines rather than inventing a new format.
You can try the result in the free web editor at autocaptions.cc (videos up to 5 minutes). The Premiere Pro and After Effects panels are part of Pro.
About the author
Full Stack Developer and Cloud Engineer with 4+ years of hands-on experience designing, developing, and implementing applications and solutions using a range of technologies, platforms, and programming languages.
Comments
Join the discussionNo comments yet. Be the first to comment.



