Opened 7 months ago

Closed 7 months ago

Last modified 7 months ago

#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 Jozef Chutka)

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)

out.png (1.6 KB ) - added by Jozef Chutka 7 months ago.

Download all attachments as: .zip

Change History (6)

by Jozef Chutka, 7 months ago

Attachment: out.png added

comment:1 by Jozef Chutka, 7 months ago

Description: modified (diff)

comment:2 by Elon Musk, 7 months ago

Resolution: wontfix
Status: newclosed

This is intended, it states in documentation it is number of input frame (from 1st input pad) and not number of output frame.

comment:3 by Jozef Chutka, 7 months 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 Elon Musk, 7 months 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 Jozef Chutka, 7 months 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.

Note: See TracTickets for help on using tickets.