Stabilizing 360 Video with Hugin

Although there are plenty of tools that work well for stabilizing regular video, there aren’t any good ones for stabilizing 360 degree video. As I was unable to find any freely available software that worked, I used various command line tools from Hugin and FFmpeg. Although this worked, it was extremely slow and had some issues with the horizon drifting.1 I can’t really recommend the approach, but I figured I’d post the technique in case anyone finds it to be useful. Hopefully Facebook with open source their 360 video stabilization, since it seems much better.

# Extract frames from original video
ffmpeg -i video.webm frame%03d.png

# Create Hugin project with frames
pto_gen -o project.pto -p 4 -f 360 frame*.png

# Find control points between adjacent frames
cpfind --linearmatch -o ctrlpoints.pto project.pto

# Remove bad control points (optional)
cpclean -p -o clean.pto ctrlpoints.pto

# Optimize fit
autooptimiser -p -o optimized.pto clean.pto

# Change output size to match input and change output mode to only remap images
pano_modify --canvas=AUTO --output-type=REMAPORIG -o output.pto optimized.pto

# Stitch output
nona -o output output.pto

# Convert remapped frames back into video
ffmpeg -framerate 30 -i output%04d.tif -c:v libvpx -b:v 10M output-no-audio.webm

# Copy audio
ffmpeg -i output-no-audio.webm -i video.webm -map 0:v -map 1:a -c:v copy -c:a libvorbis output.webm


  1. Manually adding some horizontal line control points in Hugin helped in this regard. 

This entry was posted in and tagged , , , , . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *