[FFmpeg-user] v360 / perspective
Michael Koch
astroelectronic at t-online.de
Fri Dec 4 20:19:30 EET 2020
Am 04.12.2020 um 19:06 schrieb Paul B Mahol:
> On Fri, Dec 4, 2020 at 6:58 PM Michael Koch <astroelectronic at t-online.de>
> wrote:
>
>> Am 04.12.2020 um 18:14 schrieb Paul B Mahol:
>>> On Wed, Dec 2, 2020 at 11:11 PM Michael Koch <
>> astroelectronic at t-online.de>
>>> wrote:
>>>
>>>> Am 01.12.2020 um 19:56 schrieb Michael Koch:
>>>>> Hello,
>>>>>
>>>>> there seem to be some problems in the v360 filter with "perspective"
>>>>> output.
>>>>> Tested with the latest Windows built, 2 days old. You can reproduce
>>>>> this with any equirectangular input image.
>>>>>
>>>>> ffmpeg -i equirectangular_test.png -lavfi v360=e:perspective -y
>> out1.png
>>>>> The output of the above command has two problems:
>>>>> -- The center of the input image is not mapped to the center of the
>>>>> output image. For most other projections the image center is preserved.
>>>>> -- The output is mirror reversed (which means you cannot read text).
>>>>>
>>>>> Both problems can be corrected with this workaround:
>>>>>
>>>>> ffmpeg -i equirectangular_test.png -lavfi
>>>>> v360=e:perspective:pitch=90:v_flip=1 -y out2.png
>>>>>
>>>>> Now I want to add a yaw rotation after the pitch rotation:
>>>>>
>>>>> ffmpeg -i equirectangular_test.png -lavfi
>>>>> v360=e:perspective:rorder=pyr:pitch=90:yaw=20:v_flip=1 -y out3.png
>>>>>
>>>>> But in the output you can see that a roll rotation was done.
>>>> Today I did for the very first time figure out how to compile ffmpeg.
>>>> The above problem can be solved by changing two lines in vf_v360.c
>>>> Sorry, I haven't yet figured out how to use git.One thing after the
>>>> other...
>>>>
>>>> Old version:
>>>> line 3136: vec[1] = sin_theta;
>>>> line 3137: vec[2] = cos_theta * cos_phi;
>>>>
>>>> New version:
>>>> line 3136: vec[1] = cos_theta * cos_phi;
>>>> line 3137: vec[2] = sin_theta;
>>>>
>>>> I'm not sure if lines 3139 to 3141 must also be changed.
>>>>
>>>>
>>> Good job!
>>> Please write a patch with correct authorship and send it to the devel
>> list.
>>> Fixing this for you was much more work than writing & sending patch will
>> be.
>>
>> lol, fixing this problem was done in 10 minutes. Since 3 days I'm trying
>> to figure out how git works. Git is the pure horror! I think I have the
>> patch file now, but now the next problem is that the subscription to the
>> ffmpeg-devel list doesn't work.
>>
>
> Just send it here then.
From 45c633b47ef7a702e432fa377e154aa554699bd5 Mon Sep 17 00:00:00 2001
From: Michael Koch <astroelectronic at t-online.de>
Date: Fri, 4 Dec 2020 17:22:17 +0100
Subject: [PATCH] Fixes several problems with 'perspective' output: The image
center wasn't preserved, the output image was mirror reversed, and
rotations
were made around wrong axes. I did also remove the vector normalization,
because it's sure that the vector is already normalized if it's calculated
from sin() and cos() terms.
---
libavfilter/vf_v360.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/libavfilter/vf_v360.c b/libavfilter/vf_v360.c
index 1dcad0ac69..e4e6ae5553 100644
--- a/libavfilter/vf_v360.c
+++ b/libavfilter/vf_v360.c
@@ -3133,16 +3133,14 @@ static int perspective_to_xyz(const V360Context *s,
const float cos_theta = cosf(theta);
vec[0] = cos_theta * sin_phi;
- vec[1] = sin_theta;
- vec[2] = cos_theta * cos_phi;
+ vec[1] = cos_theta * cos_phi;
+ vec[2] = sin_theta;
} else {
vec[0] = 0.f;
vec[1] = 1.f;
vec[2] = 0.f;
return 0;
}
-
- normalize_vector(vec);
return 1;
}
--
2.25.1
More information about the ffmpeg-user
mailing list