Motion Interpolation for Glitch Aesthetics using FFmpeg part 0

As you may have seen in this blog post I made use of FFmpeg’s minterpolate motion interpolation options to make all of the faces morph. There’s quite a few options for minterpolate and many different combinations of options that can be used. i had to consult Wikipedia to figure out exactly what the different motion estimation algorithms were but even with that information I couldn’t visualise how it would change the output. To add to this how I’m using minterpolate isn’t a typical use case.

To make things easier for those wishing to use FFmpeg’s minterpolate to create glitch aesthetics I have compiled 36 videos each showing a different combination of processing options. The source video can be seen below and features two of my favourite things: cats (obtained from here) and rainbows.

I’ve slowed it down so that you can see exactly what’s in the video, but the original can be downloaded here.

The base script used for each video is:

ffmpeg -i cat_rainbow_original.mp4 -filter:v "setpts=62.5*PTS,minterpolate='fps=25:mb_size=16:search_param=400:vsbmc=0:scd=none:

In part two of March’s Development Update I explained why I set scd to none and search_param to 400. I could have of course documented what happens when all of the processing options are changed but that would result in me having to make hundreds of videos! The options that were changed were the mc_mode (motion compensation mode), me_mode (motion estimation mode), and me (motion estimation algorithm).

Test conditions

These videos were created using FFmpeg 7:4.1.4-1build2, installed from the Ubuntu repositories, on a Dell XPS 15 (2017 edition) with 16GB memory, a i7 processor and an Nvidia GeForce GTK 1050 graphics card, all running on Ubuntu 19.10 using proprietary drivers.

I don’t have a Windows or Mac machine, and haven’t used other Linux distributions so can’t test these scripts in those conditions. If there’s any problems with getting FFmpeg on your machine it’s best that you contact the developers for assistance.

Observations

My first observation is that the esa me_mode takes frikkin ages to complete! Each video using this me_mode took about four hours to process. I did consider killing the script but for completeness I let it run.

Using bilat me_mode produces the most chaotic results by far. Just compare 026_mc_mode=obmc_me_mode=bilat_me=epzs.mp4 to 008_mc_mode=obmc_me_mode=bidir_me=epzs.mp4 and you’ll see what I mean.

For a video of this length nearly all of the scripts (except for those using esa) took between 30 seconds and 1 minute to complete, and that’s on machines with and without a GPU. This is good news if you don’t want to have to carry around a powerhouse laptop all the time.

All of this reminds me a bit of datamoshing. It’s more predictable and controllable, but the noise and melty movement it creates, especially some of the ones using bilat me_mode, remind me of the bloom effect in datamoshing. This could be down to the source material, and I’d be interested to see experiments involving datamoshed videos.

Let’s a go!

With that all said let’s jump into sharing the results. As there’s 36 videos I’ll be splitting it over nine blog posts over nine days, with the last being posted on 28th March 2020. Each will contain the script I used as well as the output video. Links to each part can be found below:

Glitch Webcam

Glitch Webcam* is a small script that was developed during my time at Databit.me as part of the Open Camera project, which aimed at finding inexpensive ways to take images. Since then it has been in the MEMIC exhibition in November 2012 and usually makes an appearance wherever my laptop goes.

At only five lines of code and ~254 bytes, this script is a very quick way to glitch photos taken automatically by a webcam. The project was originally demoed using a Raspberry Pi/Raspbian and a digital photo frame, though problems with USB have prevented me from doing that since.

Below is the script, which requires you to have installed Streamer, feh (1.3.4 used), sed and xdotools:

#!/bin/bash
mkdir output & streamer -s 640x480 -o ./output/glitch_00000000.jpeg -t 1000000000000 -r 0.48 &
sleep 1.8 ; feh --action1 ";sed -i s/g/2/ %f" -F -r ./output/ --force-aliasing -Z -Y --reload 1 --slideshow-delay 2 &
while true ; do xdotool key --delay 200 1 ; done

The script works by using Streamer to capture sequentially-numbered images to a folder called “output”. feh is then used to display the image and also to run a sed command, thanks to the –action1 option. Actions in feh can only be run via a key press, so xdotools is used to automatically press a key (1). feh is then finally used to display each image full-screen.

It’s not the most efficient way of glitching from a webcam – e.g. you can get glitch plugins for Pure Data, Quartz Composer and other software – but as a small utility it works well. Also, it saves all of the images so you can make an animation out of it!

Glitch Webcam

*terribly unimaginative name, I know!