by dataflow · 6y ago · 0 comments
I've Googled and tried this so many times but there are so many filters and knobs I half-understand (at best) that I haven't really managed to find one I actually like in practice, but I feel like it must be possible given that people post videos online that do this extremely well.
function stabilize {
tempfile=".temp$RANDOM$RANDOM.trf"
ffmpeg -nostdin -loglevel error -y -i "$1" -vf vidstabdetect=shakiness=5:show=1:result="$tempfile" -f null -
ffmpeg -nostdin -loglevel error -y -i "$1" -vf vidstabtransform=input="$tempfile",unsharp=5:5:0.8:3:3:0.4 -movflags +faststart "$2"
rm "$tempfile"
}
Usage: stabilize infile outfile.mp4Update: Just tried it. It seems to do some kind of blurring to smooth the vibrations over several frames instead of trying to cancel the shaking by inverse-transforming the frame with respect to the shake. I think I've tried this in my experiments before -- and I guess it's the difference between "de-shake" and "stabilization"? Sadly it doesn't really seem better to my eyes sadly, but thanks for the help anyway.
Perhaps you just need to increase the smoothing parameter. I found the default of 10 way too low, and needed around 50-100 for my very shaky 50 fps home videos.
See here: https://ffmpeg.org/ffmpeg-filters.html#vidstabdetect-1
Maybe your ffmpeg build doesn’t have it? Also try removing the log level parameter.
Not command line though.
I haven't tried either approach.
[1]: https://www.youtube.com/watch?v=nU8zqn091rM
[2]: http://blog.gregzaal.com/2014/05/30/camera-stabilisation-wit...
What Blender won't help you with (I haven't found it at least) is removing the motion blur that happens because of the camera shake. Which is fine, Blender is not a post-production tool, but worth knowing that if you want to stabilize footage, you probably need Blender + insert-favorite-post-production-tool.