How to stabilize video with Kdenlive?

17,786

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.

Share:
17,786

Related videos on Youtube

Csaba Toth
Author by

Csaba Toth

Remote team lead, full-stack developer, GDG Fresno lead, WTM Fresno ambassador, NJUG co-founder. Python/Django, C#/.NET, Java, C++ (9+ years CAD software development) development. MCPD EAD, MCITP Database Developer 2008.

Updated on September 18, 2022

Comments

  • Csaba Toth
    Csaba Toth almost 2 years

    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?

    • ravery
      ravery about 7 years
      it isn't necessary to save the project. import video. place it on time line. add the stabilizer to the video. then render.
    • Csaba Toth
      Csaba Toth about 7 years
      Whatever is necessary, what should I do to make stabilization happen? I doubt I meant to manually modify the render script. I need to figure out "add the stabilizer to the video" part. I don't see any option to do that. The motion effects contain only the freeze and speed, I see the vidtsab2 only as a clip addon.
    • ravery
      ravery about 7 years
      see the edit on my comment.
    • Csaba Toth
      Csaba Toth about 7 years
      @ravery How to do that. If I select the video on the timeline and I invoke the same menu (Project > Clip Job > Stabilize), I check "Crop", then it offers to override the mlt file. Then I repeat the step again, but it forgets that I checked the crop 10 seconds ago. It saves something but goes into /dev/null?
    • Csaba Toth
      Csaba Toth about 7 years
      @ravery When I right click on the video in the timeline I don't see any Stabilize in the context menu. Stabilization is not an effect (although that could be a good place) or transition.
    • Csaba Toth
      Csaba Toth about 7 years
      @ravery If you can tell me this how to add it, explain it in an answer I'll mark it and accept it. Both of us will be happy.
    • ravery
      ravery about 7 years
      sorry I do not know how to add it to kdenlive if it is not available in the plugin ist
  • Csaba Toth
    Csaba Toth over 5 years
    Scroll down in the referenced entry: askubuntu.com/a/947892/180266 "I tried the deshake for my helmet mounted GoPro bicycle footages but it looked like almost didn't do anything. Deshake is part of the official Ubuntu version of ffmpeg, maybe there's some parameter combination it'd work better, but reading on the net sounds like vid.stab will be better." So far I don't have any solution, but not editing these days much
  • kokbira
    kokbira about 5 years
    Later is more than 1 month waiting ;) It renders so slowly :D
  • Greg H
    Greg H almost 5 years
    What do you mean by "start a job"? Should something happen visually? When I select the menu option, nothing at all happens and I don't see any files being created.
  • kdarras
    kdarras about 4 years
    in kdenlive 20.04, there is no stabilize option anymore under "clip jobs"