English 日本語
INTERSTELLAR TECH BLOG

Converting VR180 videos to 2D videos with ffmpeg.

Youtube application screengrab

Hi, I’m Agata.

Our company has been uploading videos shot with VR180 on Youtube as an experiment for some time now. The following video was taken at random, but it seems to have been viewed unexpectedly.

Now, on this subject, there was a request to divert this VR180 video and turn it into a short video, which is very popular these days. What we had to do was convert the VR180 video to 2D video, make it into a vertical screen suitable for short videos, and cut out 15 seconds of the video.
Naturally, paid video editing tools can do this, but I wanted to automate the process because of the large number of files, so I used ffmpeg to do it.

Options for ffmpeg

I’ll start from the conclusion, but I was able to achieve this with the following command. (tested with ffmpeg 5.0.1).
The input files are taken with Insta360 EVO and exported with Insta360 Studio.

ffmpeg -i input.mp4 -vf v360=input=equirect:output=flat:ih_fov=180:iv_fov=180:h_fov=93:v_fov=121:in_stereo=sbs:w=1440:h=2560 -codec:v hevc -t 15 output.mp4
OptionProcessing details
v360Filters for VR video.
input=equirectInput file settings. equirect indicates that the input file’s projection method is equirectangular.
Since the Insta360EVO output is equirectangular, it is specified as such.
output=flatOutput file settings, specifying that the output should be in 2D with FLAT.
ih_fov=180Horizontal field of view of the input file; fixed at 180 because of VR180.
iv_fov=180Vertical field of view of the input file; fixed at 180 because of VR180.
h_fov=93Horizontal field of view of the output file.
v_fov=121Vertical field of view of the output file.
in_stereo=sbsSpecifies the stereo mode of the input file. Side by Side is specified here.
w=1440Horizontal resolution of the output file.
h=2560Vertical resolution of the output file.
-codec:v hevchevc (H.265)で再エンコードする。
-t 15Cut out 15 seconds from the head.
ffmpeg options

Regarding the FOV of the output file, this was set using the GoPro FOV values as a reference. However, this can be set arbitrarily, so you can set it to your own preference. Here, the vertical v_fov is the larger value because the output is for a short video. For normal horizontal screen output, swap the h_fov and v_fov values.

The output resolution was set as a WQHD (2560×1440) portrait screen with a value close to the original video resolution of 2880×2880 square. Here, too, the w and h values are swapped for horizontal screen output.

Finally, it is re-encoded in hevc, which is essentially unnecessary. However, this is done on purpose to remove metadata from the Insta360EVO.

It seems that the metadata of the Insta360EVO output video contains proprietary data and ffmpeg is unable to remove these parameters. For this reason, when uploaded to Youtube, the video is not recognised as a 2D video properly and is displayed strangely. To avoid this, we dare to re-encode with hevc. This is because ffmpeg does not take over metadata when re-encoding. Note that this is likely to be a problem unique to the Insta360EVO, so re-encoding may not be necessary when shooting with other VR180 cameras.

Summary

FFMPG has so many options that you can do just about anything, but finding a way to achieve what you want to do can be a challenge. This time, I had to search around quite a bit to find a way to do it. I hope it will be of help to those who have similar difficulties.