September 28th, 2024

Stabilise Video Using FFmpeg

FFmpeg stabilizes video using a two-pass method: the first pass detects shakiness and generates data, while the second applies this data to create a smoother video. Kdenlive offers similar features.

Read original articleLink Icon
Stabilise Video Using FFmpeg

FFmpeg provides a method for stabilizing video using a two-pass approach. The first pass involves using the `vidstabdetect` filter to analyze the video and generate stabilization data, which is saved in a file named `transforms.trf`. Users can adjust parameters such as shakiness, accuracy, and stepsize to optimize the detection process. For example, a command to analyze a very shaky video might look like `ffmpeg -i clip.mp4 -vf vidstabdetect=shakiness=10:accuracy=15 -f null -`, while using default parameters can be done with `ffmpeg -i clip.mp4 -vf vidstabdetect -f null -`. The second pass employs the `vidstabtransform` filter to create a stabilized video based on the data from the first pass. This step also allows for adjustments in smoothing, interpolation, and zooming, although default settings often yield satisfactory results. A typical command for this step is `ffmpeg -i clip.mp4 -vf vidstabtransform stabilised-clip.mkv`. Users can combine both passes into a single command for efficiency. Additionally, Kdenlive offers similar stabilization parameters for users who prefer a graphical interface.

- FFmpeg stabilizes video using a two-pass method.

- The first pass detects shakiness and outputs data for stabilization.

- The second pass applies the stabilization data to create a smoother video.

- Users can adjust various parameters for optimal results.

- Kdenlive provides similar stabilization features for video editing.

Link Icon 3 comments
By @jonathanyc - 4 months
I actually had no idea FFmpeg could do this.

Are there any sample videos for people to look at? I know YouTube has a very aggressive video stabilization option, but I'm sure that that's using something more complicated than what FFmpeg is doing.

Does FFmpeg implement this using the existing motion coding mechanisms?

By @elintknower - 4 months
Is it possible to replicate rotoscoping stabilization effects solely using ffmpeg? I've also been looking for a method to re-create motion blur transitions too!