Overlay n expression being off 1 frame
|Reported by:||Jozef Chutka||Owned by:|
|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
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.