Hacker News new | past | comments | ask | show | jobs | submit login
Video Stabilization with FFmpeg and VidStab (paulirish.com)
52 points by notpushkin on Aug 9, 2022 | hide | past | favorite | 9 comments



Here's a 2022-era guide on much better quality DIY video stabilization:

- Capture the gyro and accelerometer data along with your video (slap a smartphone on your camera if it doesn't have its own sensors)

- Feed both video and sensor data to gyroflow [1], synchronize and stabilize it.

The sensor-based stabilization is easy and looks uncannily good compared to pure software stabilization which is typically hit-and-miss. A good 3 axis gimbal is still better as it also compensates for parallax, but for deshaking the results are really similar.

[1] https://gyroflow.xyz/


It is mystery for me, why doesn't DLSR/System cameras doesn't store this information in video and photos. It can be useful for both - for video stabilization and for photos, taken with long exposure times, de-convolution... It is very simple technical solution, but no, nothing from Canon, Nikon, Fuji...


You have a good point and this does seem to be evolving industry practice. Sony does this in a few of their recent cameras. And Blackmagic just released a new firmware for certain Blackmagic Pocket Cinema Cameras where gyro data is stored in BRAW and then Davinci Resolve has gyro-based stabilisation. It’s not perfect, it’s not magic, it’s not a substitute for a gimbal, and there are some real limitations but that aside the results are shocking. My understanding is that rotations can be very well corrected (as it’s same camera position) but translations are not as successful. Also you typically need to shoot with higher frame rates and there is a significant crop on the resulting image. All that being said I use this frequently and my handheld casual shots are much much nicer now.


Is there an app you'd recommend to capture that motion data?

I heard about this at one point, by was stymied by not knowing what I could use to record that data in a useful format for gyroflow.


Yes, the compatible apps are listed on their github:

https://github.com/gyroflow/gyroflow#supported-gyro-sources


There are a few apps listed at the very bottom of the link: “Mobile apps: Sensor Logger, G-Field Recorder, Gyro”


The "double-bonus two-liner":

    export vid="sourcevid.mkv"
    ffmpeg -i "$vid" -vf vidstabdetect -f null -; ffmpeg -i "$vid" -vf vidstabtransform "$vid.stab.mkv"; ffmpeg -i "$vid" -i "$vid.stab.mkv"  -filter_complex vstack "$vid.stacked.mkv"
can be a one liner:

    vid="sourcevid.mkv" ffmpeg -i "$vid" -vf vidstabdetect -f null -; ffmpeg -i "$vid" -vf vidstabtransform "$vid.stab.mkv"; ffmpeg -i "$vid" -i "$vid.stab.mkv"  -filter_complex vstack "$vid.stacked.mkv"


Thanks for this but could someone include a sample video? I know this is an old post but it's not worth to install everything to make that work only to learn that the stabilization quality is subpar or that it leaves strange artifacts on videos.


The VidStab library that is using has a video: http://public.hronopik.de/vid.stab/




Consider applying for YC's W25 batch! Applications are open till Nov 12.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: