GithubHelp home page GithubHelp logo

chengzegang / insta360-air-remap Goto Github PK

View Code? Open in Web Editor NEW

This project forked from careyer/insta360-air-remap

0.0 1.0 0.0 632.75 MB

Generate remappings for Insta360 Air spherical video with ffmpeg

License: Other

Shell 18.05% C 81.95%

insta360-air-remap's Introduction

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:

insta360-air-remap's People

Contributors

96fps avatar careyer avatar chengzegang avatar prouast avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.