[FFmpeg-user] Command line calesthetics

steward at stewardware.com steward at stewardware.com
Sat Jul 23 22:48:21 EEST 2016


I have a command line that draws text at random locations, fading in and
out over a time period. 

Here is how the X and Y values are calculated: 



This works. But now I want to ensure X,Y are never dead centre.
I want to constrain them to the outer portion of the frame.

I so I write this:



The original logic chose an X value between 0 and (w-text-w), the left
and right margins.
I still do that, but then I also find the centre (V5) use that value to
choose a new random value between the left and right hand side. Left is
between 0 and V5-text_w, right is between V5 and w=text_w.

That seems to do the trick. The X,Y cords are never dead centre now.
They move around the edges. Great!

But. Now I have broken the timing.
It used to fade in, hold for SNPERIOD seconds, then fade out.
Now it just pops around very quickly.

Naturally, this is the one part of the command line I was unable to
Pulling apart the X cord logic:

st(0,ceil(t/{$this->SNPERIOD})); V0 = TOTALTIME / DISPLAY PERIOD
if(gt(ld(0),ld(1)),st(1,ld(0)); IF V0>V1 THEN V1=V0
st(2,rand(0,w-text_w))); V2 = A RANDOM NUMBER BETWEEN 0 AND RIGHT MARGIN
st(5, ceil(w/2)); V5 = mid-frame
if(gt(ld(2),ld(5)), st(2,rand(ld(5),w-text_w)), st(2,
rand(0,ld(5)-text_w)) ))

The second line baffles me. It looks like V1 (the variable defined by
st(1...) and ld(1) is used before it has a value.
I fail to grasp how exactly this keeps X at the same value for SNPERIOD
values of T.

T is the timecode: 1....600 for a ten minute clip.
SNPERIOD is 20: hold the x,y for 20 seconds.

So V0 is used like a modulus, it causes a cycle from 1 to 20 (or 0 to 19

...then...whatever it is... I don't know ;) Is there someone in the
house who has seen this kind of thing before?

I wish I knew what to ask !

How is the logic that holds it in place for 20 seconds working?
How can it be the value of ld(1) is used before it is set?

I think I am reading this "procedurally" and need a new viewpoint.....


More information about the ffmpeg-user mailing list