Everybody's seen video taken by someone who has no clue how to hold a camera properly to reduce shakiness. It seems like every time I hand my phone to my kids to try and take a picture or video, they try to make it as jumpy as possible. It's super annoying.
Or, maybe you're an outdoor enthusiast who has a bunch of video footage taken from your GoPro that seems just a little too shaky or jumpy and you'd like to smooth it just a bit. Fortunately, there is a decent way to stabilize your video so that you don't get sick while trying to watch it.
What is Video Stabilization?
Video stabilization takes out all the jumpiness from a video to make it much more smooth and easier to watch. It's best just to show you:
This video was stabilized using Virtualdub and Deshaker 2.4, both programs that you need to download and run on a Microsoft Windows computer. Now, I'm a web developer and though I prefer programming on a Mac, I can certainly spin up a virtual machine to run Windows for me, download the programs above, open them up, try to remember how to use them, spend several minutes Googling what to do again, and then hope that I configured everything correctly while the stabilization process incompacitates my computer for half an hour (or longer!) by taking up all of my CPU and memory capacity. That also assumes that I have a computer in front of me to begin with. What if I had just taken some video footage on my iPhone and didn't have a computer nearby to stabilize the video?
Now you might be able to see why outsourcing video stabilization to the cloud might be a good idea. I'm going to cover how to stabilize your videos using VidStab and FFMPEG, two great video libraries that can be run on a Linux server.
- FFMPEG installed with VidStab option. If you'd like to run this on a Mac, you could read my quick tutorial on Getting FFMPEG Up and Running on a Mac
- A shaky/jumpy video
- Access to the terminal
Stabilizing the Video
The first thing to do is analyse your video to create a
ffmpeg -i your_shaky_video.mp4 -vf vidstabdetect=stepsize=6:shakiness=8:accuracy=9:result=transform.trf -f null -
Then, once you have your
.trf file, you can stabilize your video by running:
ffmpeg -i your_shaky_video.mp4 -vf vidstabtransform=input="transform.trf":zoom=1:smoothing=30,unsharp=5:5:0.8:3:3:0.4 -vcodec libx264 -preset slow -tune film -crf 18 -acodec copy "stabilized.mp4"