Easy Guide: an easy way to stabilize your video image

środa, 6 lipca 2016

Easy Guide: an easy way to stabilize your video image


Welcome to my first guide, written in English language! Because this post is bringing me moderate success over here in Poland, I've decided to translate this post to english.

For this guide, we need two programs installed on our PC:
XMedia Recode  
and
VirtualDub with Deshaker plugin.

Please mind that guide isn't by any means addressed to proffesionals. They wouldn't need an stabilized video in the first place, this guide is directed to amateur videographers for quick'n'dirty, but quite pleasant to the eye, stabilizing.

Stabilizing video brings best results to footage that destabilization rate is low-to-moderate. The best results will be on picture taken by hand without the tripod, but not too shaky (you can't do anything with destroyed footage, unless you shoot it again). This guide bases on usage of free Deshaker plugin and the goal of this guide to eliminate any too shaky footage.

We need to download the following programs, and install them:
1. XMedia Recode - it is quite fast, handy and easy to use program to encode our footage for editing: http://www.xmedia-recode.de/en/download.html
2. VirtualDub - the legendary free video editing software with lots of features http://www.virtualdub.org/
3. Deshaker - and the most important plugin to the aforementioned VirtualDub: http://www.guthspot.se/video/deshaker.htm

Keep in mind that you can use any program for converting your footage and XMedia Recode is just a suggestion.

And finally, the guide itself:
Step 1. Preparing your footage for editing:
Let's fire up XMedia Recode. We need to convert our footage so that VirtualDub can open it. It is true that VirtualDub opens most of the formats, but some of them aren't meant to be edited or the editing will be painfully sluggish. VirtualDub best handles following formats: DivX, XviD, MJPEG, HUFFYUV, MPEG-1, MPEG-2, but due to the heavy compression H.264, x264 isn't advised, and on the contrary - just save yourself some broken PCs from anger (it is - absolutely - supported, but not accurate, sluggish, heavy on PC and generally buggy and can waste hours of your editing).




Step 2. Drag and drop your file on file list and chooose AVI container (AVI isn't a format - e.g. DivX and XviD are - AVI is not - but that's another topic).



Step 3. Enter the data as seen on screenshot. The interface is in polish on these screenshots, but there's no difference, set the format to MJPEG, also keep in mind that XMediaRecode sometimes reads FPS wrong - for example, videos shot with Android are always VFR - that means Variable Frame Rate. Sometimes it reads my files as 15FPS, when in reality it is 30FPS, so just choose value closest to the reality. Why does it read it wrong you ask? It's simple - to properly read VFR you would need to pull the VFR text data from file and the program would have to understand the VFR data. XMediaRecode doesn't do that, so it's just prediciting the frame rate, probably by reading the scene with lowest and highest frame rate and stops at medium, so when it's maximum 30FPS and 10FPS minimum, it's around 15FPS.

Anyway, I digress. Just choose the correct frame-rate.

Why choose MJPEG? It is easiest to edit and it's blazingly fast to encode. It supports any resolution you want to throw at it, but sometimes has problems with color spaces, because it doesn't support them all.


Step 4. In case of audio, you can just choose MP3 but don't use VBR (Variable Bit Rate), just stick with the Constant Bit Rate, because VirtualDub always has issues with VBR audio and can cause desync and we definitely not want that.


Step 5. When everything is set, just click on green cross (Add task or something, again the screenshots are in Polish, I will maybe add english later).


Step 6. And then, click on Convert / Start tasks. Shouldn't be too long, depending on quality / material.

2. Stabilization itself

Now that we have the footage ready for editing, just close XMediaRecode and install the Deshaker filter. To do that, you need to enter the VirtualDub directory and extract the Deshaker plugin file into Plugins / Filters directory. Keep in mind that you need to have .VDF file inside of Plugins / Filters directory, not inside another folder or VirtualDub doesn't recognize it. When you do that, you're all set.


Step 1. Drag and drop previously encoded file and enter Video -> Filters menu.

Step 2. With the Filters window already open, click Add...

Step 3. Just choose Deshaker from file list or install it properly if you don't see it.

Step 4. Now, I know this window looks like rocket science at first, but it isn't, because many of those options are completely useless I think not only for us, but for everyone else too. Most of them are redundant because if you want to analyze them you would probably end with thousands versions of your footage and stabilization of each wouldn't be noticable. So, I will quickly go through the most important options.



Video output: Motion vectors option allows us to see what the plugin is doing and None just turns the preview altogether. While it's interesting to see those arrows here and there, it's also quite CPU intensive so it equates slower analyzing time - best turned to None.

Block size: Smaller amount results in slower but more precise analyzing process. For optimal results just leave the default setting.

Scale: Full - analyzes whole frames, Half - analyzes half frame, Quarter - 1/4 frame is analyzed. I suggest choosing Half because Quarter is definitely too small but fast, and Full can be an overkill.

Use pixels: This option can trigger pixel skipping in analisis. If you choose full - it will analyze each pixel (overkill), you can choose to skip some pixels, shouldn't cost much quality.

Color mode: Grayscale - the analisis will be in black and white, which is faster, RGB - analises color. For the first glance, you may think this doesn't make any difference, but believe me, it hurts the speed quite a lot.

I think these options are the most important. Now click OK (don't exit using the cross because it won't save settings) and OK again (to exit Filters). No just push the button as seen on the screenshot below.


Now the filter is analyzing - the so called 1 Pass. It is the most time intensive task but also the most important. Just leave your PC on and do something else. May take a while, of course depending on CPU. When it will arrive to the end of the video, it is done.

Now after it is done, let's get back to Deshaker in Filter and now it should read Pass 2. If not, just click on Pass 2.

Now for the final settings before encoding.

Resampling - Bicubic is recommended - because the picture will be resized in different sizes on different frames you absolutely need some kind of filter, Bicubic is the most basic, but also fastest and most effective. Looks alright.

Edge compensation - None (large borders) - this setting is not recommended, as it's just shows us black borders around stabilized frame. Adaptive zoom (some borders) or Adaptive zoom only will definitely reduce black borders, but it doesn't eliminate them altogether. Next options are Fixed zoom (no borders) - it eliminates the black borders, but zooms picture really close, hurts resolution and overall viewing experience, Adaptive+fixed (no borders) and Adaptive+fixed only does something similar to previous option, but doesn't hurt picture so much so it is probably the best option.

As seen on the screenshot above, next options allows us to set up the speed in which the image is stabilized. Setting the amount too high, while the image is stabilized, may actually bring us an opposite effect - the image will give us sea-sickness like experience because the image will roll here and there.

Now - again click OK and OK.

Now we can preview our efforts by clicking play button with 0 on it. It looks kind like shot on a tripod! Success!


 Here is a friendly word of advice. Since nothing in the world can beat a video shot on tripod or other means of stabilizing picture, the results may vary. The better the picture in beginning, the better will be the results. We can lose a lot of resolution and the results may be worse than the original video itself. Some badly clips that I converted that way could induce some kind of sea sickness - they were wavy and had a lot of motion blur.

Interesting idea, would be shooting a video with a 4K smartphone, and then, because of excessive additional resolution stabilizing it, but to 1080P picture. That would result in practically zero resolution loss because it would use the additional pixels. But it is another topic.


Now we must just enter into Video -> Compression, choose compression format - I suggest HuffYUV or MJPEG again. You may also choose other encoders but those will be far slower.

Now we must choose File -> Save as AVI...,name our file and wait for it to be converted.
If we don't like AVI - we just need to change the container. So don't convert the file yet again, just choose different container - MKVtoolnix for MKV files, YAMB for MP4 files.


Now you won't need to puke everytime you watch your hand shot movies.

Proffesionals are probably laughing at this tutorial - it involves converting the file at least two times, so the quality can be hurt pretty badly. But the results are quite good for casual home viewing.

Alternative solution would be just uploading video to YouTube, clicking Yes on prompt wheter to stabilize the video (yes, YouTube has that), waiting a bit and the downloading the video from YouTube already stabilized. The results are, however, a little better on Deshaker part.

0 komentarze :

Prześlij komentarz