Rendering .srt Subtitles with ffmpeg (OS X / Linux)

Image for post
Image for post

Some media players handle subtitles well and others… not so much. Rather than leaving it to chance, I like to render the subtitles right into the video. ffmpeg is an excellent tool for this.

Grab ffmpeg if you don’t already have it. In OS X you can use brew.

Or use a package manager in Linux:

Either way, you want to make sure you have the libass (Advanced Sub Station) renderer in there. Most package manager versions have this but if you are compiling from source you want to --enable-libass.

A popular format for subtitles is .srt which is just a text file. It looks like this:

You’ll want to convert .srt file into an .ass file.

The result of that is another text file with a little more information that looks like this:

Now comes the fun part. Render the subtitles into the video with ffmpeg:

Now you should have subtitles rendered into the video!

I’ve had timing problems, for example all titles show up 11.75 seconds too late. The correct fix would be to adjust all the numbers in the .srt (which I’m sure some subtitling software can do easily) but I just added 11.75 seconds of blank screen to the source, rendered it and then trimmed away the beginning.

Hope you find this helpful.

Applied CBDC Research @ the Federal Reserve — fmr Circle.com, Bandwidth.com. MIT / Podcaster / Runner / Helicopter Pilot

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store