Skip to content

Instantly share code, notes, and snippets.

Last active March 16, 2023 15:18
Star You must be signed in to star a gist
What would you like to do?
Video stabilization using VidStab and FFMPEG (Mac OS X)

Video stabilization using VidStab and FFMPEG

Examples here use the default settings, see the VidStab readme on GitHub for more advanced instructions.

Here's an example video I made

Install ffmpeg with the vidstab plugin from homebrew

brew install ffmpeg --with-libvidstab

Analyze your video to create a .trf file

This won't modify your video or create a new video, but it should create a new file called transform.trf

ffmpeg -i -vf vidstabdetect -f null -

Use the .trf file to create a stabilized video

ffmpeg -i -vf vidstabtransform=smoothing=5:input="transforms.trf"

This should create a new stabilized video called

Bonus: create a side by side comparison video

Found on a forum here

ffmpeg -i -i -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w"
Copy link

yefim commented Dec 10, 2019

Looks like varenc/ffmpeg/ffmpeg has been superseded by homebrew-ffmpeg/ffmpeg according to

Copy link

silasfc commented Dec 10, 2020

What is -f null - do?

This (-f null -) occurs because when performing step 1 (vidstabdetect) we do not (yet) need the final video file, but only "transforms.trf", necessary for step 2 (vidstabtransform).

By the way: "-f" specifies the output format (null in this case) for ffmpeg.

Copy link

gth001 commented Oct 31, 2021

Edits from 2021. There's some errors/inefficiencies above due to changes since it was written (in Dec 2015).

With ffmpeg -i clip.mkv -vf vidstabdetect -f null -I just get the error
No such filter: 'vidstabdetect'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment