FFMpeg Video Stabilization

FFMpeg Video Stabilization

FFMpeg is a command line video processing tool that has granular, if not sub atomic controls to process audio and video data. It will do a high degree of processing and since it uses the CLI, this allows its use in the background for bulk jobs. This ability puts FFMpeg out front of other processing tools.

I’ve used GUI tools like vReveal, VirtualDub, and ProDAD. vReveal was an impressive tool that allowed me to leverage CUDA which used GPUs from my video card. However it was a Windows based GUI that required a license. I purchased it and was, like many of you, disappointed when the product support was discontinued. It was no longer available for download and I could not install it on future hardware. VirtualDub became an alternative, but took many steps to achieve the same results. Using VirtualDub requires interaction with the GUI and automation is not easy. ProDAD offered some great stabilization as well as other processing abilities. However, investing money into a program of which the developers can pull support without warning discouraged me from pursuing it further. Enter FFMpeg.

In this post I’ll cover some basic video processing using FFMpeg. I won’t go into great detail here. That amount of information can be found at the FFMpeg Documentation site, it is extensive. I’m just going to skim through using FFMpeg to enhance and stabilize video taken from one of my 808-16 720p helmet cameras. The footage is shaky. This makes it hard to make out what was captured with the camera. I’ll show the commands used to stabilize that source video. Lets begin.

Ubuntu 14.x Linux will not have FFMpeg installed by default. If you get the “command not found” message, yours does not. To install it, enter these commands.

sudo add-apt-repository ppa:mc3man/trusty-media
sudo apt-get update
sudo apt-get dist-upgrade
sudo apt-get install ffmpeg

Now when you enter “ffmpeg” into the command line you will get the version information as well as some other info.

Here is the source video that I’ll want to stabilize. Its a short 5 second clip of a bike ride on the Burke Gilman Trail near Children’s Hospital. There was a path that was recently added, but the details are hard to make out because of the video wobble.

To stabilize the video, I used these 2 commands. The first command creates a file “transforms.trf” which profiles shakes in the video, the next applies the profile to stabilize the video.

ffmpeg -i MINI0016_Split.MOV -vf vidstabdetect=shakiness=10:accuracy=15 -f null -
ffmpeg -i MINI0016_Split.MOV -vf vidstabtransform=smoothing=30:input="transforms.trf" MINI0016_Split.MOV

Here is the resulting video. I’ve lost some of the outside edges from the original. But it is easier to make out details that were obscured by the camera shake.

Even though this is a short clip, the ability to post process video this way is fantastic. No longer will I need to sit in front of a computer doing repetitive steps for each video. Now I can apply stabilization to several long length videos and let the computer do all the work.

FFMpeg is an amazing tool for audio and video processing. In the next months, I’ll be covering some topics I have found useful. Please join me as we explore the possibilities of FFMpeg. Thanks go out to the following folks that informed and inspired this post.

All you FFMpeg developers
0612 TV w/ NERDfirst
Scott Miller
Norman Black

Comments are closed.