#9455 closed defect (wontfix)
Overlay n expression being off 1 frame
Reported by: | Jozef Chutka | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | 4.3.2 | Keywords: | overlay n |
Cc: | Jozef Chutka | Blocked By: | |
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description (last modified by )
Summary of the bug:
Using ffmpeg 4.4
It seems to me that when using overlay, the n
expression is actually 1 frame off. To prove it, I managed to put together the following demo.
How to reproduce:
ffmpeg -filter_complex_script filter.txt -ss 1 -frames:v 1 output/out.png -y
filter.txt:
color=black:300x320:8[main]; color=red:64x100:8[red]; color=white:2x100:8,scale=eval=frame:w=n*10:h=ih[white1]; [white1][red]overlay=x=(W-w)/2[red]; color=green:64x100:8[green]; color=white:2x100:8,scale=eval=frame:w=n*10:h=ih[white2]; [white2][green]overlay=x=(n*10-64)/2[green]; color=blue:64x100:8[blue]; color=white:2x100:8,scale=eval=frame:w=n*10:h=ih[white3]; [white3][blue]overlay=x=((n-1)*10-64)/2[blue]; [main][red]overlay[main]; [main][green]overlay=y=110[main]; [main][blue]overlay=y=220
What I am doing here is, I am animating position of these red/green/blue bars in order to center within its growing white container.
The containers width is n*10
, bar is 64, so expected formula to center would be (n*10-64)/2
(same as (W-w)/2
). However, when applied, the green bar is not centered.
I am able to center using ((n-1)*10-64)/2
. This makes me think that the n
expression in overlay is for some reason off by 1.
Attachments (1)
Change History (6)
by , 3 years ago
comment:1 by , 3 years ago
Description: | modified (diff) |
---|
comment:2 by , 3 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
comment:3 by , 3 years ago
Thanks for your quick reactins Elon.
I was under impression that the frame numbering in my whole example should be equal/synced for all used sources. When printing n
with drawtext it renders the same value for any source used.
Do I get it right that n
in overlay starts at 1 while in all other filters starts with n
being 0? And so, for scale=w=n
(n
is i.e. 0) while following overlay=x=n
filter has different n
- being 1 already.
Can you please point me to the documentation that would explain it in more details.
comment:4 by , 3 years ago
Dunno really, did it in older version returned right 0 from start?
If not, i'm a bit reluctant to change it this late.
comment:5 by , 3 years ago
4.3 does the same, older versions complains a lot about n
being used in scale so I am not able to test.
Are we in agreement there is something suspicious happening?
I understand changing this might have big consequences.
This is intended, it states in documentation it is number of input frame (from 1st input pad) and not number of output frame.