Enhance your shitposting with FFMPEG

Colin Wren
3 min readMar 11


My shitpost

I was watching one my favourite movies — An American Werewolf in London the other day and realised that the scene where the doctor visits the Slaughtered Lamb and asks about the Pentagram on the wall would make a good joke about team’s attitudes to legacy code by replacing the pentagram with a jQuery logo and the term ‘paint over it’ with ‘refactor it’.

I used to have an Adobe After Effects license but I got rid of that £50 leech on my bank account so I had to find a means of creating my ‘vision’ using only free (and open source) tools — FFMPEG, VLC and InkScape.

Extracting the scene from the movie

I started by extracting the scene from the movie file itself using FFMPEG, taking note of the time stamps the scene started and ended.

I decided to convert the scene to h264 in order for it to play better in Finder’s preview ( -c:v libx264 does this) and downmix the surround sound to stereo ( -c:a ac3 -ac 2 takes care of that).

ffmpeg -ss 00:50:04 -i movie.mkv -t 00:00:20 -c:v libx264 -c:a ac3 -ac 2 scene.mp4

Creating the jQuery logo overlay graphic

In order to create the overlay I needed to extract a frame from the scene that I could use as a reference for where the jQuery logo should be placed. Using -vframes 1 I was able to extract a single frame for the purpose.

ffmpeg -i scene.mp4 -vf "select=eq(n\,34)" -vframes 1 frame.png

I then fired up InkScape, imported the frame and an SVG of the jQuery logo that I downloaded from the internet and exported just the transparent layer with the logo in position.

Creating subtitles

I had originally hoped to have just amended the subtitles already in the movie but they were in an image based format so it would have proved hard to do this.

I instead opted to hand writing my own as the scene was only 20 seconds long and didn’t have much dialogue. The SRT format for subtitles makes it really easy to do this by defining the start and end timestamps and the words to display.

I used VLC and it’s Time extension to find accurate timestamps for the subtitles and then used the ‘Add Subtitles File` option to import the .srt file I was working on to check it sync’d up.

00:00:04,500 --> 00:00:05,500
Oh, what's that?

00:00:06,000 --> 00:00:10,000
Oh, that's been there for 200 years sir

00:00:10,500 --> 00:00:15,000
We were going to refactor it out, but it's traditional so we left it

Adding the jQuery logo to the scene

In order to add the overlay graphic I created for placing the jQuery logo over the pentagram I used FFMPEG to overlay the graphic at specific timestamps.

ffmpeg -i scene.mp4 -i overlay.png -filter_complex "[0:v][1:v] overlay=0:0:enable='between(t,0,5.3)'" -pix_fmt yuv420p -c:a copy withOverlay.mp4

There are two parts of the scene where the logo needed to be shown, technically there is a means to have one CLI command to do this but I opted to do it in stages as it allowed me to focus on the timings of each part.

Baking subtitles into the scene

Once I was happy with the timings in my subtitles I then had to ‘bake’ them into the clip, normally you can attach the subtitles but they will only show when the user chooses to show them, but in order for the joke to work they needed to be part of the clip itself.

ffmpeg -i withOverlay.mp4 -vf subtitles=subs.srt withSubtitles.mp4 

I experimented with using some of the styling options that FFMPEG supplies but I couldn’t find a more legible font than the default.

Final steps

After baking in the subs I uploaded the clip to various places to make everyone’s day that ever so slightly worse having seen it.


FFMPEG is a powerful CLI tool that makes it really simple to work with video without the need to spend a lot of money on a tool like Adobe After Effects and I’m forever grateful for the developers of it for gifting us with it.



Colin Wren

Currently building reciprocal.dev. Interested in building shared understanding, Automated Testing, Dev practises, Metal, Chiptune. All views my own.