1- # Insta360 360-degree video processing in command- line
1+ # Insta360 360-degree video processing from the command line
22
33This repository contains the utility and instructions to process
44Insta360 360-degree videos (with extension ` .insv ` ) from the command line,
@@ -7,52 +7,88 @@ Studio](https://www.insta360.com/download/insta360-x3) (Insta360's desktop
77editing software).
88
99If you are a Linux user, this utility can come in handy, because as of early
10- 2025, Insta360 Studio has not shipped a Linux version.
10+ 2025, Insta360 Studio has not shipped a Linux version.
1111
1212## Prerequisites
1313
1414- A machine that runs Docker
15- - Enough free space on your local file system to store original and processed
16- video files
15+ - Enough free disk space to store original and processed video files
1716- [ Fill out the application] ( https://www.insta360.com/sdk/home ) , get approved,
1817 and download the Insta360 media SDK for Linux
1918 - The latest media SDK I have access to is ` LinuxSDK20241128.zip ` . It contains
2019 a pre-built package ` libMediaSDK-dev_2.0-6_amd64_ubuntu18.04.deb ` for Ubuntu
2120 18.04, which is the only file I need from the zip.
2221 - According to [ Insta360's
2322 note] ( https://github.com/Insta360Develop/Desktop-MediaSDK-Cpp/blob/cb70fdf197ac55473e876a010f297192e6e20e3e/README.md?plain=1#L3 ) ,
24- GPU is required in version 3.x.x. For better portability, we suggest that
25- you use an earlier version of the media SDK.
23+ GPU is required in version 3.x.x. If your computer doesn't have an NVIDIA
24+ GPU, we suggest that you use an earlier version of the media SDK.
2625
2726## My workflow for converting and joining 360-degree videos
2827
29- 1 . Clone this repo .
28+ 1 . Clone this repository .
3029
3130 ``` bash
3231 git clone https://github.com/syncom/insta360-cli-utils.git
3332 ```
3433
35- 2 . Extract the aforementioned ` .deb ` file from the media SDK zip, and put it
36- under the directory root of the just cloned repository.
34+ 2 . Extract the aforementioned ` .deb ` file from the media SDK zip, and place it
35+ in the root directory of the cloned repository.
3736
38- 3 . Build the Docker container image in which the SDK is installed.
37+ 3 . Build the Docker container image in which the SDK is installed. Suppose the
38+ file's name is ` libMediaSDK-dev_2.0-6_amd64_ubuntu18.04.deb ` .
3939
4040 ``` bash
41- # Under repo's directory root
42- docker build --tag ubuntu:insta360 .
41+ # From the repository root
42+ docker build --tag ubuntu:insta360 \
43+ --build-arg=" MEDIASDK_UBUNTU_DEB=libMediaSDK-dev_2.0-6_amd64_ubuntu18.04.deb" .
4344 ```
4445
45- 4 . Run the container, mounting host directory ` datadir/ ` to the container's path
46- ` /root/ ` , for host-container data sharing.
46+ 4 . Run the container, mounting the host directory ` datadir/ ` to the container
47+ path ` /root/datadir ` , for host-container data sharing.
48+
49+ <details >
50+ <summary >If you don't have an NVIDIA GPU</summary >
51+
52+ As mentioned above, you need to use a media SDK whose version is below
53+ ` 3.0.0 ` . In this case, you can perform video processing using the CPU.
54+
55+ ``` bash
56+ docker run -v " $( pwd) /datadir" :/root/datadir --rm -it ubuntu:insta360
57+ ```
58+ </details >
59+
60+ <details >
61+ <summary >If you have an NVIDIA GPU</summary >
62+
63+ You can use the GPU for video processing (tested on a PC with NVIDIA GeForce
64+ RTX™ 4060 Ti running Ubuntu).
65+
66+ Before running the Docker container with CUDA support, perform the following prerequisite steps:
67+
68+ 1 . Install the [ NVIDIA Container
69+ Toolkit] ( https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html )
70+ 2 . Configure Docker so that it can use the NVIDIA Container Runtime
71+
72+ ``` bash
73+ sudo nvidia-ctk runtime configure --runtime=docker
74+ # restart the Docker daemon
75+ sudo systemctl restart docker
76+ ```
77+
78+ The above steps only need to be done once on the host PC. Now you can run the
79+ CUDA container.
4780
4881 ` ` ` bash
49- docker run -v " $( pwd) /datadir" :/root/datadir -it ubuntu:insta360
82+ docker run --runtime=nvidia --gpus all \
83+ -v " $( pwd) /datadir" :/root/datadir \
84+ --rm -it ubuntu:insta360
5085 ` ` `
86+ < /details>
5187
52- Copy/ move ` .insv ` files to "$(pwd)/ datadir" on host, for processing in the
88+ Copy or move ` .insv` files into ` datadir/ ` on the host for processing in the
5389 container.
5490
55- 5 . Inside the Docker container, in shell prompt
91+ 5. Inside the Docker container, at the shell prompt:
5692
5793 ` ` ` bash
5894 MERGED_VIDEO=" merged.mp4"
@@ -66,7 +102,7 @@ If you are a Linux user, this utility can come in handy, because as of early
66102 MediaSDKTest -inputs " $i " -output " ${i} .mp4" \
67103 -enable_directionlock -enable_flowstate -enable_denoise
68104 done
69- # Join MP4 files into one (assuming file names are sorted in time order)
105+ # Join MP4 files into one (assuming filenames are sorted in chronological order)
70106 ls * .mp4 > list.txt
71107 sed -i.bak ' s/^/file /g' list.txt
72108 ffmpeg -safe 0 -f concat -i list.txt -vcodec copy -acodec copy " $MERGED_VIDEO "
@@ -80,15 +116,15 @@ If you are a Linux user, this utility can come in handy, because as of early
80116 -o " $MERGED_VIDEO_360 "
81117 ` ` `
82118
83- "$MERGED_VIDEO_360" is the merged 360-degree video that can be viewed in [ VLC
84- media player] ( https://www.videolan.org/ ) or uploaded to YouTube as a 360
119+ ` " $MERGED_VIDEO_360 " ` is the merged 360-degree video that can be viewed in
120+ [VLC media player](https://www.videolan.org/) or uploaded to YouTube as a 360
85121 video.
86122
87123 For 5.7K videos, separate video files like
88124 ` /path/to/VID_20240528_113402_00_032.insv` and
89125 ` /path/to/VID_20240528_113402_10_032.insv` are generated by the camera for
90126 the left-eye and right-eye views. Both files need to be supplied to the
91- ` -input ` argument of ` MediaSDKTest ` , in the aforementioned order. For
127+ ` -inputs ` argument of ` MediaSDKTest` , in the aforementioned order. For
92128 example,
93129
94130 ` ` ` bash
@@ -99,18 +135,27 @@ If you are a Linux user, this utility can come in handy, because as of early
99135 -enable_directionlock -enable_flowstate -enable_denoise
100136 ` ` `
101137
138+ 6. Clean up ` datadir/`
139+
140+ After processing is complete and you have copied the files you need out of
141+ ` datadir/` , you can remove its contents from the repository root with:
142+
143+ ` ` ` bash
144+ git clean -df datadir/
145+ ` ` `
146+
102147# # Utility: `join-insv`
103148
104149The utility ` join-insv` is available in the container to automate the above
105- workflow. Example
150+ workflow. Example:
106151
107152` ` ` bash
108153# For 4K and lower resolution
109154join-insv --output /path/to/merged_360video.mp4 \
110- /path/to/input-1. insv /path/to/input-2.insv ...
155+ /path/to/input-1.insv /path/to/input-2.insv ...
111156
112157# For 5.7K
113- join-insv --output /path/to/merged_5.7k_360video.mp4 \
158+ join-insv --is_57k -- output /path/to/merged_5.7k_360video.mp4 \
114159 /path/to/VID_20240528_113402_00_001.insv /path/to/VID_20240528_113402_10_001.insv \
115160 /path/to/VID_20240528_120003_00_002.insv /path/to/VID_20240528_120003_10_002.insv \
116161 ...
0 commit comments