Skip to content

Seals at Newburgh Seal Beach – Deshaking a Video with Mac, ffmpeg and vid.stab

I had no idea that taking a video using my 300 mm zoom would be that shaky. Anyway, there is help at hand. Do you spot the difference between the left-hand side (original) and the right-hand side (stablized) in the video of the seals above–in full resolution, it is much more astounding, btw.? How did I go about it? This is how:

1) I got homebrew for my Mac. From this page I copied the command and pasted it into a terminal window I had opened before. This istalled homebrew on my computer.
2) I had homebrew install ffmpeg by just typing “brew install ffmpeg” into the terminal. ffmpeg came with the vid.stab filter enabled already.
3) I went to the folder my shaky video was in by typing “ls ” into the terminal and dragging the folder from the bread crumb trail in finder.
4) Now the filter works in two passes.
4a) First pass: command: “ffmpeg -i -vf vidstabdetect -f null -“. This writes a file named “transforms.trf” into the same folder.
4b) Second pass: command: “ffmpeg -i -vf vidstabtransform=smoothing=5:input=”transforms.trf””. This writes the stabalized clip into the folder.
5) That’s it.

Max Ogden (commands in 4 are from his text) also adds a command to creade a side-by-side comparrison here.

You might want to rescale your video. Info on that filter of ffmpeg here.

Depending on the shakiness of your video, you might want to adapt the filter options a bit. On the website of vid.stab, you will find explanations on how to do that. I have found that with this really shaky video, it seems to work fine if I put shakiness to the maximum of 10 in the first pass (default is 5) and the smoothing to 30 (default is 10) in the second (see command line summary below).

Command Line Summary:

/usr/bin/ruby -e "$(curl -fsSL"
brew install ffmpeg
ls ***folder***
ffmpeg -i ***seals***.MP4 -vf vidstabdetect=shakiness=10 -f null -
ffmpeg -i ***seals***.MP4 -vf vidstabtransform=smoothing=30:input="transforms.trf" ***seals***-stabilized.MP4
ffmpeg -i ***seals***.MP4 -i ***seals***-stabilized2.MP4 -filter_complex "[0:v:0]pad=iw*2:ih[bg]; [bg][1:v:0]overlay=w"
ffmpeg -i -vf scale=1080:-1

Post a Comment

Deine E-Mail-Adresse wird nicht veröffentlicht oder weiter gegeben. Um deinen Kommentar verarbeiten zu können, muss das Gelblog die von dir eingegebenen Daten und deine IP-Adresse speichern. Wenn du damit einverstanden bist, betätige Bitte den Knopf *Daten speichern und Kommentar abschicken*. Weitere Informationen findest du in der Datenschutzerklärung. Required fields are marked *