Ubuntu – How to stabilize video with Kdenlive

kdenlivevideo

I'm using kdenlive 16.12.3 (with Ubuntu Studio 17.04), so this cannot be the How to get the stabilization function working in Kdenlive? issue I assume since that bug supposed to be fixed a good while ago.

What I'm doing:

  1. I add the video clip I want to stabilize to the project. Then I can right click on the clip and add videostab2 (Clip Job > Stabilize), looks the same as the screenshot included in the SO issue I referenced above. But when I do this nothing happens.

  2. When I save, eventually an .mlt file appears next to the source video file. I can see that it has some info about videostab2 (see mlt-service towards the end we can see videostab2's parameters):

    20928
    pause
    GOPR0444.MP4
    2
    video
    29.97
    0
    2704
    1524
    0
    29.97
    yuvj420p
    1
    709
    1
    h264
    H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10
    44963086
    2017-06-08T11:08:26.000000Z
    eng
    GoPro AVC
    GoPro AVC encoder
    audio
    fltp
    48000
    2
    aac
    AAC (Advanced Audio Coding)
    128000
    2017-06-08T11:08:26.000000Z
    eng
    GoPro AAC
    avc1
    0
    avc1isom
    2017-06-08T11:08:26.000000Z
    HD3.03.03.00
    1
    1
    1
    1
    1
    0
    1
    avformat
    30000
    1001
    709
    1
    2704
    1524
    0
    1

    4
    8
    6
    1
    0.3
    0
    10
    -1
    -1
    1
    0
    1
    0
    1
    0.8
    videostab2
    GOPR0444.MP4.mlt.trf
    0

  3. I place the clip on the playlist.

  4. I render.

For reference when I generate the render script it doesn't contain any traces of videostab. Not surprisingly the end result is not stabilized at all.

How can I get this working?

Best Answer

To stabilize a specific video file I import the file into kdenlive, right-click on it, select "clip jobs" and then "stabilize".

This will start a "job" which produces a file with .mpi appended to the end of the original video file name.

Then remove the original video from the project file list, add the .mpi video file, put that in the timeline and render it.

The problem is that this .mpi file will only work in the project environment in which it was created. It also takes a lot more time than the length of the original video because the processing is single-threaded. Then there are possible memory issues with large files. So creating a large video and then stabilizing it is a very time and memory-intensive process, requiring at least as much memory and swap-space and multiples of the time required to create that large video in kdenlive without stabilizing it. It's a good argument for an IS video camera or at least breaking the unstabilized final product into chunks and stabilizing the chunks in groups which will not require use of the swap file, then combining all the stabilized chunks into one final project and rendering it.

Then there is the effectiveness of the stabilization pass...kdenlive gives you a lot of options to play with, all affect speed, memory requirements, IQ and stabilization. Or you can try using the ffmpeg tools directly which requires a new level of understanding and effort...but at least it's possible.

Deshaking videos using script

in any case it will help immensely to do this at low-res and figure it all out before trying to do it on unstabilized files straight from the camera shot at high resolutions especially at high frame-rates. My 4Gig laptop just spent 5 days stabilizing a 30min 5GB 4k-30fps h265 mp4 video. Now I'm trying to figure out how best to render the .mpi file. I'm considering just rendering the final product at 720p or at least at 1080p. It took 8 hrs or so to render the original unstabilized 5GB 4k product at moderate IQ and encoding settings that was a mixture of 12MP stills and 1080p video...and that was for 30 minutes of 4k video. My fear is that trying to render a final product at 4k is going to ask too much of the 4GB ram + 1GB swap that I have currently and it simply has to be done at 1080p to match the original video components. So I'll try that first and update this later.

Related Question