{"id":77,"date":"2022-06-21T00:50:15","date_gmt":"2022-06-20T15:50:15","guid":{"rendered":"https:\/\/blog.interstellar.co.jp\/en\/?p=77"},"modified":"2022-06-21T00:50:16","modified_gmt":"2022-06-20T15:50:16","slug":"converting-vr180-videos-to-2d-videos-with-ffmpeg","status":"publish","type":"post","link":"https:\/\/blog.interstellar.co.jp\/en\/2022\/06\/21\/converting-vr180-videos-to-2d-videos-with-ffmpeg\/","title":{"rendered":"Converting VR180 videos to 2D videos with ffmpeg."},"content":{"rendered":"\n<p>Hi, I&#8217;m Agata.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<figure class=\"wp-block-embed is-type-video is-provider-youtube wp-block-embed-youtube wp-embed-aspect-16-9 wp-has-aspect-ratio\"><div class=\"wp-block-embed__wrapper\">\n<iframe loading=\"lazy\" title=\"[VR180] \u4eac\u60251000\u5f62\u30012100\u5f62(\u30d6\u30eb\u30fc\u30b9\u30ab\u30a4\u30c8\u30ec\u30a4\u30f3)\u30011500\u5f62\u304c\u4eac\u6025\u5ddd\u5d0e\u7b2c\u4e00\u8e0f\u5207\u3092\u7206\u8d70\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/ayWcHwHwjn0?feature=oembed\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe>\n<\/div><figcaption>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.<br>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.<\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Options for ffmpeg<\/h2>\n\n\n\n<p>I&#8217;ll start from the conclusion, but I was able to achieve this with the following command. (tested with ffmpeg 5.0.1).<br>The input files are taken with Insta360 EVO and exported with Insta360 Studio.<\/p>\n\n\n\n<pre class=\"wp-block-code is-style-dark\"><code>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<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-table is-style-regular\"><table><thead><tr><th>Option<\/th><th>Processing details<\/th><\/tr><\/thead><tbody><tr><td>v360<\/td><td>Filters for VR video.<\/td><\/tr><tr><td>input=equirect<\/td><td>Input file settings. equirect indicates that the input file&#8217;s projection method is equirectangular.<br>Since the Insta360EVO output is equirectangular, it is specified as such.<\/td><\/tr><tr><td>output=flat<\/td><td>Output file settings, specifying that the output should be in 2D with FLAT.<\/td><\/tr><tr><td>ih_fov=180<\/td><td>Horizontal field of view of the input file; fixed at 180 because of VR180.<\/td><\/tr><tr><td>iv_fov=180<\/td><td>Vertical field of view of the input file; fixed at 180 because of VR180.<\/td><\/tr><tr><td>h_fov=93<\/td><td>Horizontal field of view of the output file.<\/td><\/tr><tr><td>v_fov=121<\/td><td>Vertical field of view of the output file.<\/td><\/tr><tr><td>in_stereo=sbs<\/td><td>Specifies the stereo mode of the input file. Side by Side is specified here.<\/td><\/tr><tr><td>w=1440<\/td><td>Horizontal resolution of the output file.<\/td><\/tr><tr><td>h=2560<\/td><td>Vertical resolution of the output file.<\/td><\/tr><tr><td>-codec:v hevc<\/td><td>hevc (H.265)\u3067\u518d\u30a8\u30f3\u30b3\u30fc\u30c9\u3059\u308b\u3002<\/td><\/tr><tr><td>-t 15<\/td><td>Cut out 15 seconds from the head.<\/td><\/tr><\/tbody><\/table><figcaption>ffmpeg options<\/figcaption><\/figure>\n\n\n\n<p>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.<\/p>\n\n\n\n<p>The output resolution was set as a WQHD (2560&#215;1440) portrait screen with a value close to the original video resolution of 2880&#215;2880 square. Here, too, the w and h values are swapped for horizontal screen output.<\/p>\n\n\n\n<p>Finally, it is re-encoded in hevc, which is essentially unnecessary. However, this is done on purpose to remove metadata from the Insta360EVO.<\/p>\n\n\n\n<p>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.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>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.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Hi, I&#8217;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. Options for ffmpeg I&#8217;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. Option Processing details v360 Filters for VR video. input=equirect Input file settings. equirect indicates that the input file&#8217;s projection method is equirectangular.Since the Insta360EVO output is equirectangular, it is specified as such. output=flat Output file settings, specifying that the&#8230;<\/p>\n","protected":false},"author":2,"featured_media":79,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"vkexunit_cta_each_option":"","footnotes":""},"categories":[18],"tags":[19,20],"class_list":["post-77","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-application","tag-ffmpeg","tag-vr"],"_links":{"self":[{"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/posts\/77","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/comments?post=77"}],"version-history":[{"count":1,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/posts\/77\/revisions"}],"predecessor-version":[{"id":78,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/posts\/77\/revisions\/78"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/media\/79"}],"wp:attachment":[{"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/media?parent=77"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/categories?post=77"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.interstellar.co.jp\/en\/wp-json\/wp\/v2\/tags?post=77"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}