[FFmpeg-user] gif overlay miscalculating x and y, extra frame flash

Paul B Mahol onemda at gmail.com
Mon Feb 10 11:34:51 EET 2020

On 2/10/20, Michael Koch <astroelectronic at t-online.de> wrote:
> Am 10.02.2020 um 09:35 schrieb Paul B Mahol:
>> On 2/10/20, Michael Koch <astroelectronic at t-online.de> wrote:
>>> Am 09.02.2020 um 23:51 schrieb S Andreason:
>>>> Hi,
>>>> I continued building and rendering after asking some questions last
>>>> week. After 6 days x10 hours per day of
>>>> (render,test,measure,edit,repeat) I finally was able to publish my
>>>> video. In doing so I made it easy to duplicate the bugs I have been
>>>> seeing.
>>>> I have put the 7 files together in one 56Mb package for you to
>>>> download at
>>>> https://www.seahorsecorral.org/videos/tests/ffmpeg-test-gif.zip
>>>> The issue is with -i gif and
>>>> overlay=x=(calculations):y=(calculations):between
>>>> 1. between calculates n differently than the 30fps video,
>>>> 2. the last calculation for x and y are held over in memory for the
>>>> next overlay, resulting in offsets and drift over time.
>>> I have a similar problem, not sure if it's the same as yours, but it's
>>> easier to reproduce.
>>> A small black rectangle is overlaid over a video, and its position is
>>> shifted to the right by one pixel per second. Theoretically we should
>>> see 9 steps in the 10s video. But I see only 4 steps, in 2s intervals.
>>> ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i color=black:size=20x40
>>> -lavfi overlay=x=400+t:y=200 -c:v mpeg4 -q:v 0 -y -t 10 out.mp4
>> You reasoning is completely invalid. And ffmpeg output is correct.
>> Next time read more documentation with understanding and learn how to
>> use overlay format option.
> When I add :format=rgb then all steps are indeed visible. I don't
> understand why it doesn't work with the default yuv420 format. Doesn't
> yuv420 mean "full resolution for luminance, half resolution for color"?
> The black rectangle has a different luminance than the background. Can
> you please explain why half of the steps are invisible?

Because yuv420 uses half resolution for color, and even no color means
it needs to store some value in frame, 128 in this case.

> Nevertheless I have the same problem as the original poster, also when I
> add :format=rgb. Something is wrong with the x,y calculations in the
> overlay filter. In my example I'm using sendcmd to set x and y. The
> coordinates are sometimes off by a few pixels. At the moment my command
> line is too complicated to show here. Give me a little bit of time to
> find an example that's easier to reproduce.

No, as already said if timebases and fps do not match you can not get
results you expect.
Use fps filter somehow...

> Michael
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".

More information about the ffmpeg-user mailing list