Deshaking videos with Linux

This blog post is more or less for my own, that I don’t forget how to deshake a video if I need it again. Reading several blog posts and forum threads how to deshake a video, I have found the solution. Most Linux distributions have already installed it, without any knowledge of their users.

I’m speaking about “transcode”. If you don’t have transcode installed, install it:

pacman -S transcode

transcode includes a video stabilizier and you just have to know how to use it. You can update only the stabilizer by downloading a new version here and overwrite the exisiting files, but I don’t recommend it. You must download the binary version if you want to update.

Now we will start to deshake our video. Open a terminal, change to your directory with your videos and let us start:

  1. transcode must analyze our video, so start the command:

    transcode -J stabilize -i yourmovie.avi

    If transcode complains about not supported format, then try the following:

    transcode -J stabilize --mplayer_probe -i yourmovie.avi
    (this will use mplayer to decode the file, which should be able to decode everything :) )

  2. The next step will stabilize your video. You have several options here, have a look at the plugins project page to find out what is possible.

    transcode -J transform --mplayer_probe -i yourmovie.avi -y raw -o yourstabilizedmovie.avi (Here is an example video from the project page. This will produce a large new video file, because I have taken the output “raw”. If you want another output then you have to specify it after -y, e.g . “-y xvid4″. Or you can send the output to ffmpeg, how to do this you have to look into the manual of transcode.)

    The result will be zoomed so you don’t see how transcode moved the image to deshake it. If you want to see it, then try the following command:

    transcode -J transform=crop=1:optzoom=0 --mplayer_probe -i yourmovie.avi -y raw -o yourstabilizedmovie.avi

    This will end up with a video and a black border around it which is moving around. Here is an example video from the project page.

 

That’s all. Now you have a stablilized video. You can change some parameters like shakiness and zoom factor and so on, but the standard values making good results.

You can find the deshake plugin project page for transcode here: http://public.hronopik.de/vid.stab/features.php?lang=en
All parameters and options are described there. If you want to output the result to ffmpeg you have to read the wiki or manual of transcode, you can find the project page here: http://www.transcoding.org

This is an example from the project page, it looks amazing how good it stabilize the original source:

About these ads

,

  1. #1 by masteryod on 22. March 2011 - 14:06

    wow!

  2. #2 by Ken Yu on 31. May 2011 - 07:31

    Really appreciated your hard works for this important tools for Linux. Looks forward to see a GUI for this tools. Thanks

    • #3 by Alastair Gilfillan on 27. November 2013 - 11:49

      I know this is a very late response but Kdenlive has an option to stabilise a clip (with options as sliders) and import the result straight into your project! :-)

  3. #4 by mentar on 19. July 2011 - 18:11

    Great and much needed tool! Still trying to get it to analyse it though but even with mplayer_probe still ends up with the likes of:
    [filter_stabilize.so] warning: unsupported Codec: 2 (10| 1| 9)
    Will try playing around a bit more and worst comes to worst convert it to raw with ffmpeg and feed it back in
    Many thanks!

  4. #5 by Ash on 6. February 2012 - 16:07

    Thanks for posting the instructions here. It’s unsurprisingly difficult searching for help on “transcode”, because it’s such a common word.

  5. #6 by Joseph on 6. October 2012 - 02:28

    @mentar: I originally had the same issue, it seemed to go away after getting the most recent binary from here: http://public.hronopik.de/vid.stab/download.php?lang=en

    @OP: However, now the first command seems to hang on “[decoder.c] cancelling the import threads: 0:00:57, (15| 0| 5)”, any advice?

  6. #7 by Daniel on 29. December 2012 - 23:03

    @OP/Joseph
    I stumbled into the same issue. Couldn’t get it to work. I assume it’s either transcoder or mplayer not supporting YUV4, but I coulnd’t recompile transcoder 1.1.7 for testing this out, because I ran into a c error in ‘filter_pp.c’ “Unknown type name ‘pp_mode_t’ and ‘pp_context_t’”. The error when running the stabilize-command above is:

    [extract_yuv.c] critical: No support for YUV4MPEG compiled in.
    [extract_yuv.c] critical: Recompile with mjpegtools support enabled.
    [decoder.c] cancelling the import threads

    Transcode version 1.1.7

    • #8 by atom on 23. March 2013 - 02:33

      Get rid of “–mplayer_probe”.

  7. #9 by robynsveil on 6. October 2013 - 08:12

    Well done, mate – this rocks! I’m using Lightworks Linux beta (free download) – they’ve gone open-source – but my steadycam video and even on a monopod video has a shocking tremor to it – you’ve totally saved the day!

  8. #10 by Robin Hahn on 24. November 2013 - 11:56

    I’ve got .mov files, which transcode says it doesn’t have codecs for. Any suggestions?

    I looked up the most recent release of transcode (1.1.7) but it’s not a binary and I’m not real good at compiling without a lot of hand-holding.
    For example, my most recent effort:

    sed -i ‘s|doc/transcode|&-$(PACKAGE_VERSION)|’ $(find . -name Makefile.in -exec grep -l ‘docsdir =’ {} \;) && ./configure –prefix=/usr –enable-libmpeg2 && make

    failed with this error:

    ERROR: option ‘–enable-libavcodec’ failed:
    libavcodec can be found in the following packages: libavcodec http://www.ffmpeg.org/

    ERROR: option ‘–enable-libavformat’ failed:
    libavformat can be found in the following packages: libavformat http://www.ffmpeg.org/

    ERROR: option ‘–enable-libmpeg2′ failed:
    libmpeg2 can be found in the following packages: libmpeg2 http://libmpeg2.sf.net/

    ERROR: option ‘–enable-lame’ failed: cannot link against libmp3lame
    libmp3lame can be found in the following packages: lame http://www.mp3dev.org/

    ERROR: option ‘–enable-libdvdread’ failed: cannot link against libdvdread
    libdvdread can be found in the following packages: libdvdread http://www.dtek.chalmers.se/groups/dvd/downloads.shtml

    ERROR: option ‘–enable-libjpeg’ failed: cannot compile jpeglib.h
    jpeglib.h can be found in the following packages: jpeg ftp://ftp.uu.net/graphics/jpeg/

    ERROR: option ‘–enable-libjpeg’ failed: cannot link against libjpeg
    libjpeg can be found in the following packages: jpeg ftp://ftp.uu.net/graphics/jpeg/

    …and yet I KNOW I have libavcodec and libavformat installed because I checked in Synaptic beforehand.

    Any help would be appreciated.

  9. #11 by John Doe on 19. December 2013 - 17:52

    No worky

    [filter_stabilize.so] Image Stabilization Settings:
    [filter_stabilize.so] shakiness = 4
    [filter_stabilize.so] accuracy = 4
    [filter_stabilize.so] stepsize = 4
    [filter_stabilize.so] algo = 1
    [filter_stabilize.so] mincontrast = 0.300000
    [filter_stabilize.so] show = 0
    [filter_stabilize.so] result = video.avi.dvd.trf
    [filter_stabilize.so] Fieldsize: 4, Maximal translation: 4 pixel
    [filter_stabilize.so] Number of used measurement fields: 2 out of 9
    [filter_unsharp.so] unsharp: 7×7:-1.00 (blur luma)
    [filter_unsharp.so] unsharp: 3×3:0.00 (don’t touch chroma)
    [filter_unsharp.so] v1.0.1 (2003-10-27) unsharp mask & gaussian blur
    [export_null.so] v0.1.2 (2001-08-17) (video) null | (audio) null
    [transcode] warning: The ‘mplayer’ program could not be found.

    [transcode] warning: Please check your installation.

    [transcode] critical: audio import module error: OPEN failed
    [transcode] critical: failed to open input source

    i dunno what this means but I think it’s a bad thing.

  1. Janhouse » Linux video stabilizators

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: