Skip to content

Generate remappings for Insta360 Air spherical video with ffmpeg

License

Notifications You must be signed in to change notification settings

careyer/Insta360-Air-remap

 
 

Repository files navigation

Insta360-Air-remap

This code generates remapping projections for ffmpeg to convert from dual-fish-eye images/video (spherical) to equirectangular output. It can be used to map both images and video.

The code was adapted from examples given for ffmpeg's RemapFilter, with added support for video captured with Insta360 Air devices.

Guide

Building

  1. Install ffmpeg, (make sure it's a recent version)
  2. Checkout the source of this repository
  3. Build: gcc projection.c -lm -o project

Running

1.) Create remapping lookup-tables xmap.pgm and ymap.pgm:

$ ./project -x xmap.pgm -y ymap.pgm -h 960 -w 960 -c 1920 -r 960 -m theta --verbose

This creates two ASCII encoded PGM files which act as a lookup table for ffmpeg to remap the video.

2.) Apply the maps to the video:

$ ffmpeg -i input.mp4 -i xmap.pgm -i ymap.pgm -q 0 -lavfi "format=pix_fmts=rgb24,remap" remapped.mp4

There are various pre-generated lookup tables included:

  1. camera in uptight position (USB connector down) run: ./remap_vid_down.sh

  2. camera in hanging position (USB connector up) run: ./remap_vid_up.sh

  3. camera placed sideways (USB connector right or left) run: ./remap_vid.sh

Known issues

The Lens mapping isn't perfect yet. Unfortunatly the "seam" between both pictures will only be perfect for objects that have a certain/specific distance from the camera. This distance can be fine tuned in the code but it will be fixed. Basically this image illustrates the challange quite well:


In this example the distance is perfectly tuned for Distance "B"....
Hence creating a crop effect at Distance "C" and an Overlap effect at Distance "A".

Useful Things for Spherical Video

Tag for upload

If you want to upload your video to youtube as a 360 video, make sure you encoded it as a .mp4, and use this tool from google. On linux, you can install python-tk and use the gui, or use it via command line.

The instructions there say to run python spatialmedia but there isn't anything called that, so replace spatialmedia with __main__.py and it works.

python __main__.py -i remapped.mp4 remapped_injected.mp4

Your file is now ready for YouTube/etc.

Stabilize video with Hugin

Stabilizing output videos via Hugin with Matthew Petroff's method reveals a wobble that would not be present if the mapping was perfect; Convieniently, I think i can use Hugin's Lens Calibration tools on the source frames to find a better mapping.

Some referrence links:

About

Generate remappings for Insta360 Air spherical video with ffmpeg

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 81.9%
  • Shell 18.1%