Skip to main content

Video Stabilization

What is Video Stabilization?

Video Stabilization is an algorithm that stabilizes the recorded video to smoothen any jitters, shaking, or abrupt movements from the user's camera movement.

There are multiple different approaches to Video Stabilization, either software- or hardware-based. Video Stabilization always crops the image to a smaller view area so it has room to shift the image around, so expect a "zoomed-in" effect. Also, since Video Stabilization is a complex algorithm, enabling it will increase the time the Camera takes to initialize.

Software Based Video Stabilization

A software-based Video Stabilization mode uses CPU or GPU based algorithms that keep track of the camera movement over time by using multiple past frames to compare the change in pixels.

Hardware Based Video Stabilization

Hardware-based Video Stabilization algorithms work with the gyroscope sensor on the device and an actual moving part on the Camera lens to immediately cancel out any abrupt movements like jitters or shaking from the Camera.

Using Video Stabilization

To use Video Stabilization, you need to select a format (see "Camera Formats") that supports the given Video Stabilization mode:

const format = useCameraFormat(device, [
{ videoStabilizationMode: 'cinematic-extended' }
])

Then, pass the format to the Camera and enable the videoStabilizationMode prop if it is supported:

const format = ...
const supportsVideoStabilization = format.videoStabilizationModes.includes('cinematic-extended')

return (
<Camera
{...props}
format={format}
videoStabilizationMode={supportsVideoStabilization}
/>
)

Now, the video pipeline will stabilize frames over time.

Latency

Video stabilization will introduce an additional latency in the video capture and frame processor pipeline as frames will need to be processed before being available to VisionCamera. With the most advanced video stabilization setting, you can expect delays of up to 3 seconds.

  • For Video Capture: stopRecording(...) will take longer to actually complete the recording.
  • For Frame Processors: Frames will arrive at a later point in time. If a Frame just arrived with cinematic-extended video stabilization, it might already be 3 seconds old.
  • For Skia Frame Processors: Since Skia Frame Processors have to process the Frames first before drawing them onto the Preview, this now means that the Preview is also delayed by the latency of the video stabilization algorithm. If you use Skia Frame Processors, it is recommended to use fast software-based-, or no video stabilization at all.

🚀 Next section: GPS Location Tags