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

Michael Koch astroelectronic at t-online.de
Sat Jul 16 23:12:59 EEST 2022


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.

ffmpeg -f lavfi -i color=color=white:size=1920x1080 -lavfi 
drawbox=color=gray:t=1 -frames 1 -y mask.png

ffmpeg -f lavfi -i testsrc2=size=1920x1080 -i mask.png -lavfi 
multiply=offset=0 -frames 1 -y test.png

Then use test.png as input for your script.

Michael



More information about the ffmpeg-user mailing list