26

Is there any way, either through a graphical program or a command line utility to "stabilise" video in Ubuntu?

By stabilise I am referring mainly to a feature of iMovie where shaky video is analysed, and then frame by frame altered to make it look smoother. This method looses video quality through zooming and rotating to produce the effect. Look at this video for an example of what I mean.

8128
  • 28,740
  • I don't know much about video, but the shakiness in your example doesn't look like the kind of shakiness those apps are designed to eliminate. Perhaps try mounting it on the frame, rather than your helmet? – Stefano Palazzo Feb 28 '11 at 17:43
  • couldn't you do it in ubuntu? – Lincity Mar 01 '11 at 15:18

9 Answers9

15

The transcode package bundles an image stabiliser plugin vid.stab. Their video demo certainly looks convincing (if a little vomit inducing).

Transcode package is no longer maintained and was removed from Ubuntu releases 18.04 and newer. You may still be able to run it but functions may be limited or buggy.

Oli
  • 293,335
9

You can try Cinelerra,

Installing cinelerra

  • Add the following PPA ppa:cinelerra-ppa/ppa (How to add a PPA) then install cinelerra from the software center.

Tutorials

  • Have a look at this.
karthick87
  • 81,947
  • Looking at that tutorial is quite disappointing - compared to what I'm used to in iMovie then the process is lengthy, and the result does not seem as good either. – 8128 Dec 28 '10 at 17:08
8

Apparently, ffmpeg can be used now with vid.stab to produce good quality stabilized videos. There are a few sources (1, 2, 3) that report this.

If your video is named input.mp4 execute

$ ffmpeg -i input.mp4 -vf vidstabdetect=shakiness=10:accuracy=15:result="mytransforms.trf" -f null -
$ ffmpeg -i input.mp4 -vf vidstabtransform=smoothing=30:input="mytransforms.trf" -c:a copy out_stabilized.mp4

The first step creates the stabilization profile. The second step creates the stabilized video. Other options for the second step are

$ ffmpeg -i input.mp4 -vf vidstabtransform=input="mytransforms.trf",unsharp=5:5:0.8:3:3:0.4 -c:v libx264 -crf 16 -c:a copy -preset fast out_stabilized.mp4
$ ffmpeg -i input.mp4 -vf vidstabtransform=smoothing=30:input="mytransforms.trf" -codec:v libx264 -crf 18 -preset veryslow -pix_fmt yuv420p -c:a copy out_stabilized.mp4

(the last is for high quality output).

More information on the parameters can be found in the vid.stab GitHub page.

Related:

  1. https://stackoverflow.com/questions/6515289/open-source-implementations-of-video-stabilization/10725141#10725141
  2. https://unix.stackexchange.com/questions/5638/video-editor-w-stabilization
  3. https://dashcamtalk.com/forum/threads/how-to-stabilizing-your-video.19189/
  4. How to stabilize video with Kdenlive? (further details on how to use Kdenlive).

Extra

  1. I have found a plugin for ImageJ, which is an outstanding image processing and analysis software used in many applications.
  • as above, this worked for me from link below

    I had to convert avi to mp4 first using ffmpeg -i

    https://rainnic.altervista.org/en/how-stabilize-video-using-ffmpeg-and-vidstab?language_content_entity=en

    – pierrely Feb 25 '22 at 04:04
  • vid.stab developer says "Make sure that you use unsharp filter provided by ffmpeg for best results (only in second pass)." Maybe unsharp filter should already be in the first suggested 2nd command. – Mario Mey Jun 16 '23 at 13:49
8

FFmpeg deshake filter.

ffmpeg -i "$INPUT" -vf deshake=rx=64:ry=64:blocksize=32 -strict -2 "$NEW_NAME"  ## :opencl=1

The higher the video resolution is, the more you need in rx, ry and blocksize. Check the link for documentation.

Here's a little script I use:

INPUT=$1
BASE_NAME=`basename "$INPUT"`
BASE_NAME="${BASE_NAME%.*}"
SUFFIX=${INPUT##*.}
NEW_NAME="$BASE_NAME"-deshake.$SUFFIX

set -x
ffmpeg -i "$INPUT" -vf deshake=rx=64:ry=64:blocksize=32 -strict -2 "$NEW_NAME"  ## :opencl=1
set +x
##  Copy the modification date too.
touch "$NEW_NAME" -r "$INPUT"

Although, I have to add, the results are not too good. I'd say it's better to upload to Youtube, let it deshake and download the result.

6

You can easily stabilize videos with Kdenlive:

Right-click on a clip in the project library and select Clip Jobs -> Stabilize

enter image description here

Worked with Kdenlive 20.08.2 on Ubuntu 20.10

rubo77
  • 32,486
4

You can try Shotcut (http://shotcut.org/). It's a NLE (Non linear editor) that comes with a lot of filters, including video stabilizing. check out this tutorial: https://www.youtube.com/watch?v=C3v-jYJJfuM

3

Blender is a free and open-source 3D creation suite. You can define tracking points to remove shakiness, bumps and jerks from video footage using the 2D video stabilization feature.

To install Blender Run:

sudo apt update
sudo apt install blender

Alternatively, The latest version (3.0.1) can be Downloaded from the Blender Website.

Video stabilization instructions are documented in the Blender 3.0 Manual

Here is a basic overview to use the Stabilization Feature:

  1. Tap on "open" to load the video clip.

  2. Click on the "set scene frame" located on the left to generate the video timeline.

  3. Click on "Tracking settings" and select locRot. Add as many markers as you want for location and rotation.

  4. Now click on the "Stabilization" tab to enable 2D stabilization.

    enter image description here

  5. Select the tracks for location and rotation you marked earlier.

  6. Tap on "clip display" located at the top and select "show stable".

    enter image description here

  7. Now click on "Autoscale". Or if you prefer to adjust according to your preference then you can move the slider to get the desired results.

  8. Play the video and enjoy the stable version of your footage.

  9. Tap on "save" to save the video clip.

Error404
  • 7,440
stumblebee
  • 3,547
0

vidstab1.1 will work but is not simple to implement vidstab1.1 website and it's componenets are available via synaptic.