[FFmpeg-trac] #9455(undetermined:new): Overlay n expression being off 1 frame

FFmpeg trac at avcodec.org
Fri Oct 15 15:03:13 EEST 2021


#9455: Overlay n expression being off 1 frame
--------------------------------------+----------------------------------
             Reporter:  Jozef Chutka  |                     Type:  defect
               Status:  new           |                 Priority:  normal
            Component:  undetermined  |                  Version:  4.3.2
             Keywords:  overlay n     |               Blocked By:
             Blocking:                |  Reproduced by developer:  0
Analyzed by developer:  0             |
--------------------------------------+----------------------------------
 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 input/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.
-- 
Ticket URL: <https://trac.ffmpeg.org/ticket/9455>
FFmpeg <https://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list