I need to stabilize a video only when the video is shaky.

I have successfully stabilized a video using FFmpeg, and I do not need to stabilize all the videos, I only need to stabilize the videos which appear shaky (not stable).

Is there any way I can detect that?

  • 1
    ffmpeg does not have a built in function to do this. You're basically needing to write an algorithm that will analyze pixels frame by frame. Dec 11, 2018 at 14:27

4 Answers 4


Try ffmpeg's deshake filter. It scans the full frame (or a portion of your choosing) and detects shake based on a number of adjustable variables. If the video isn't shaking, it doesn't change the content. You can run the default settings with:

ffmpeg -i [input] -vf deshake [output]

Great little demo here. It's a combination detection and repair tool, no need to separately identify videos then reprocess.


You can cut the part you want to stabillize, you can count the seconds you want to stabillize, then you stabillize it, cropping may appear. You need to edit, whether you want to scale and enlarge all video parts or other editing ways based on what you want.

  • 3
    He's looking for a way to have the computer automatically detect whether or not a video is shaky. He knows how to stabilize it. Dec 11, 2018 at 20:14

You can use any Video Editing Software e.g Adobe Premier Pro, you can see frame by frame, if the frames contained Double-lined, Shaky Motion-blur frames, then Stablize it as you say. You can use Sharpen on Mask Layers on top of Video to see, because you can see shaky after Sharpen. Or you can see the shaky by mute your audio, and Make it Slow Motion for while, remember to change it back to normal speed.

In fact that you have to find where's shaky by your own manually. Because this year still haven't come out Auto-Detect Shaky Video Plugin or Software. But, it is already has Plugin for perfect shaky detection & Stablize Plugin here. You can find more Perfect plugin for you video editing software.

Only a Programmer, can let Python Script in software help them auto-detect it. Here's Script But, the video will broke if you use that scripting.

The best option to avoid Shaky Video is Buy a Video Stablizer, it is a tool for stable video.


I think you're looking for a way to automatically detect shaky footage. You can kind of do this in After Effects, assuming that there are consistently trackable points in the background of your footage.

Import your footage into after effects. Set up a couple of motion tracking points Analyse motion tracking across your footage open the twirly controls on your layer until you find the Confidence value. Examine the confidence values over time. When it drops dramatically, your footage is shaking.

This could be automated further by using an expression to highlight where the footage is shaky, or by exporting the confidence keyframes into a spreadsheet alongside the video timings.

I suspect there's a better tool for doing things like this (maybe inside ffmpeg or DaVinci resolve?) but I don't know...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.