[FFmpeg-user] multiple flat videos in a equirectangular projection - v360 filter

Denis Połeć denis.polec at gmail.com
Sun Jul 17 15:19:49 EEST 2022



> Am 17.07.2022 um 13:54 schrieb Michael Koch <astroelectronic at t-online.de>:
> 
> Am 17.07.2022 um 12:09 schrieb Denis Połeć:
>> 
>>> Am 16.07.2022 um 22:12 schrieb Michael Koch <astroelectronic at t-online.de>:
>>> 
>>> Am 16.07.2022 um 20:57 schrieb Denis Połeć:
>>>>> Am 16.07.2022 um 11:46 schrieb Paul B Mahol <onemda at gmail.com>:
>>>>> 
>>>>> On Sat, Jul 16, 2022 at 11:22 AM Denis Połeć <denis.polec at gmail.com> wrote:
>>>>> 
>>>>>> Hello,
>>>>>> I wouldn't call myself a beginner, but I still need a little bit to become
>>>>>> a pro. :)
>>>>>> I have a question that might be easy to answer.
>>>>>> 
>>>>>> I am working on a script to bring multiple flat videos into a
>>>>>> equirectangular projection by using v360 filter.
>>>>>> I have the problem that the edges of the input are very jagged.
>>>>>> 
>>>>>> This did not lead to a good result when I play the equirectangular
>>>>>> projection in a 360 player. I have also already tried different
>>>>>> interpolation modes, which does not lead to a better result.
>>>>>> Does anyone have an idea how I can avoid that? Is there a better way to do
>>>>>> this task?
>>>>>> 
>>>>>> 
>>>>>> Here is an example code with the result. The video in the example has a
>>>>>> resolution of 1080p:
>>>>>> 
>>>>>> 
>>>>>> ffmpeg -i BRAIN.mp4 -lavfi "\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw='0':alpha_mask=1[fg1];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=90:alpha_mask=1[fg2];[fg2][fg1]overlay[a];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=-90:alpha_mask=1[fg3];[fg3][a]overlay[b];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=180:alpha_mask=1[fg4];[fg4][b]overlay[c];\
>>>>>> \
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=0:pitch=45:alpha_mask=1[fg5];[fg5][c]overlay[d];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=90:roll=45:alpha_mask=1[fg6];[fg6][d]overlay[e];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=-90:roll=-45:alpha_mask=1[fg7];[fg7][e]overlay[f];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=180:pitch=-45:alpha_mask=1[fg8];[fg8][f]overlay[g];\
>>>>>> \
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=0:pitch=-45:alpha_mask=1[fg9];[fg9][g]overlay[h];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=90:roll=-45:alpha_mask=1[fg10];[fg10][h]overlay[i];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=-90:roll=45:alpha_mask=1[fg11];[fg11][i]overlay[j];\
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=180:pitch=45:alpha_mask=1[fg12];[fg12][j]overlay[k];\
>>>>>> \
>>>>>> 
>>>>>> [0]v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=0:pitch=90:alpha_mask=1[fg13];[fg13][k]overlay[l];\
>>>>>> [0]drawbox=w=1:h=1:color=black,v360=input=flat:output=e:id_fov=45:w=5120:h=2560:yaw=0:pitch=-90:alpha_mask=1[fg14];[fg14][l]overlay"
>>>>>> -q:v 4 -vframes 1 -y test11.jpg
>>>>>> 
>>>>>> Your filtergraph is extremely inefficient with that many cascaded overlays
>>>>> and gives poor results. For proper stitching borders need to have small
>>>>> transition from full opacity to no opacity.
>>>>> 
>>>>> To add small transitions with opacity on borders could use blurring filters
>>>>> for example on alpha plane only.
>>>> How could I achieve that? How can I blurry just the borders?
>>> You could apply some preprocessing to your input video, before you feed it to your script.
>>> The trick is to multiply all pixels at the edges by 0.5. This can be done with a white mask which has gray pixels at the edge.
>>> 
>> Thank you for your reply.
>> 
>>> ffmpeg -f lavfi -i color=color=white:size=1920x1080 -lavfi drawbox=color=gray:t=1 -frames 1 -y mask.png
>> This works.
>> 
>>> ffmpeg -f lavfi -i testsrc2=size=1920x1080 -i mask.png -lavfi multiply=offset=0 -frames 1 -y test.png
>> But ffmpeg says multiply filter doesn’t exist.
> 
> Get a newer version. The multiply filter was added not so long ago.



I am on an M1 Apple machine and it seems I have the latest stable version I can get: 5.0.1_3.

---
ffmpeg version 5.0.1 Copyright (c) 2000-2022 the FFmpeg developers
  built with Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  configuration: --prefix=/opt/homebrew/Cellar/ffmpeg/5.0.1_3 --enable-shared --enable-pthreads --enable-version3 --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librist --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvmaf --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libspeex --enable-libsoxr --enable-libzmq --enable-libzimg --disable-libjack --disable-indev=jack --enable-videotoolbox --enable-neon
  libavutil      57. 17.100 / 57. 17.100
  libavcodec     59. 18.100 / 59. 18.100
  libavformat    59. 16.100 / 59. 16.100
  libavdevice    59.  4.100 / 59.  4.100
  libavfilter     8. 24.100 /  8. 24.100
  libswscale      6.  4.100 /  6.  4.100
  libswresample   4.  3.100 /  4.  3.100
  libpostproc    56.  3.100 / 56.  3.100
Input #0, lavfi, from 'testsrc2=size=1920x1080':
  Duration: N/A, start: 0.000000, bitrate: N/A
  Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 25 tbr, 25 tbn
Input #1, png_pipe, from 'mask.png':
  Duration: N/A, bitrate: N/A
  Stream #1:0: Video: png, rgb24(pc), 1920x1080 [SAR 1:1 DAR 16:9], 25 fps, 25 tbr, 25 tbn
[AVFilterGraph @ 0x131e085b0] No such filter: 'multiply'

—

 brew info ffmpeg
ffmpeg: stable 5.0.1 (bottled), HEAD
Play, record, convert, and stream audio and video
https://ffmpeg.org/
/opt/homebrew/Cellar/ffmpeg/5.0.1_3 (272 files, 48.4MB) *
  Poured from bottle on 2022-06-28 at 22:56:20
From: https://github.com/Homebrew/homebrew-core/blob/HEAD/Formula/ffmpeg.rb
License: GPL-2.0-or-later
==> Dependencies
Build: nasm ✔, pkg-config ✔
Required: aom ✔, dav1d ✔, fontconfig ✔, freetype ✔, frei0r ✔, gnutls ✔, lame ✔, libass ✔, libbluray ✔, librist ✔, libsoxr ✔, libvidstab ✔, libvmaf ✔, libvorbis ✔, libvpx ✔, opencore-amr ✔, openjpeg ✔, opus ✔, rav1e ✔, rubberband ✔, sdl2 ✔, snappy ✔, speex ✔, srt ✔, tesseract ✔, theora ✔, webp ✔, x264 ✔, x265 ✔, xvid ✔, xz ✔, zeromq ✔, zimg ✔



> 
> Michael
> 
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org <mailto:ffmpeg-user at ffmpeg.org>
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user <https://ffmpeg.org/mailman/listinfo/ffmpeg-user>
> 
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org <mailto:ffmpeg-user-request at ffmpeg.org> with subject "unsubscribe".



More information about the ffmpeg-user mailing list