[FFmpeg-user] Please increase the number of variables
Michael Koch
astroelectronic at t-online.de
Wed Jun 8 07:17:45 EEST 2022
Am 03.06.2022 um 17:30 schrieb Paul B Mahol:
> On Fri, Jun 3, 2022 at 5:05 PM Michael Koch <astroelectronic at t-online.de>
> wrote:
>
>> Hello,
>>
>> I'd like to ask if the number of variables in expressions could be
>> increased from 10 to 25 please. I mean the st() and ld() functions. I'm
>> just programming a realtime wormhole simulation and the limitation to 10
>> variables is becoming nasty. I did already begin to re-use the same
>> variables for different things, but that makes debugging complicated. It
>> would be so much easier to have more variables and use each one only for
>> one thing.
>> What you see below is only a small part of the code.
>>
> Why you doing that way, this is the most inefficient way to do it.
How would you do it instead? Sure, it's possible to generate the mapping
files with C or C# code.
Pro C code:
+ No limit for the number of variables.
+ The code can be commented in the same line.
+ It's very helpful to get error messages for division by zero,
sqrt(-1), asin(2), log(0), log(-1).
Pro FFmpeg code in batch file:
+ A whole project can be written in one batch file and executed with
just one double-click. No compiler required.
+ The mapping files are automatically generated in the correct working
folder, no problems with files in wrong folder.
In the meantime I got the code for a realtime wormhole (with fisheye
projection in a planetarium) running with just 10 variables (see below).
I had to re-use some of the variables, which is error-prone. I also had
to use many if/ifnot functions to avoid overwriting of variables. With
12 variables the code would have been simpler.
I have some ideas for even more complex transformations, but with the
limitation to just 10 variables they are impossible to implement.
Michael
ffmpeg -f lavfi -i nullsrc=size=%OUT_W%x%OUT_H% -vf
format=pix_fmts=gray16le,geq='^
st(0,%OUT_H_FOV%/180*((2*X+1)/%OUT_W%-1));^
st(1,%OUT_V_FOV%/180*((2*Y+1)/%OUT_H%-1));^
st(2,atan2(ld(1),ld(0)));^
st(3,PI/2*hypot(ld(0),ld(1)));^
st(4,sin(ld(3))*cos(ld(2)));^
st(5,sin(ld(3))*sin(ld(2)));^
st(6,cos(ld(3)));^
st(1,if(lt(ld(6),cos(%OUT_H_FOV%/360*PI)),32767,0));^
st(0,ld(5)*cos(%PITCH2%/180*PI)-ld(6)*sin(%PITCH2%/180*PI));^
st(6,ld(6)*cos(%PITCH2%/180*PI)+ld(5)*sin(%PITCH2%/180*PI));^
st(5,ld(0));^
st(7,atan2(ld(5),ld(4)));^
st(8,acos(ld(6)));^
st(9,if(lte(ld(8),%RS%/180*PI),1));^
if(ld(9),st(7,ld(8)*cos(ld(7))));^
ifnot(ld(9),st(8,ld(8)-%S%*(2*%RS%/180*PI/(ld(8)-%RS%/180*PI))));^
ifnot(ld(9),st(4,sin(ld(8))*cos(ld(7))));^
ifnot(ld(9),st(5,sin(ld(8))*sin(ld(7))));^
ifnot(ld(9),st(6,cos(ld(8))));^
ifnot(ld(9),st(0,ld(5)*cos(%PITCH1%/180*PI)-ld(6)*sin(%PITCH1%/180*PI)));^
ifnot(ld(9),st(6,ld(6)*cos(%PITCH1%/180*PI)+ld(5)*sin(%PITCH1%/180*PI)));^
ifnot(ld(9),st(5,ld(0)));^
ifnot(ld(9),st(7,atan2(ld(5),ld(4))));^
ifnot(ld(9),st(8,acos(ld(6))));^
ifnot(ld(9),st(7,atan2(sin(ld(8))*cos(ld(7)),cos(ld(8)))));^
if(ld(9),0.5*%IN_W2%*(1+180/PI/%RS%*ld(7)),ld(1)+0.5*%IN_W%*(1+ld(7)/PI))'
-frames 1 -y xmap.pgm
More information about the ffmpeg-user
mailing list