I am trying to move a png image by 10px over a white background during 2s (fps=25), but the transition I got is not smooth.

Here is the command I am using:

ffmpeg -y -vsync passthrough -f lavfi -i color=c=white:size=300x250 -loop 1 -framerate 25 -i image.png -filter_complex "[0][1]overlay=eval=frame:format=yuv444:x=120:y=lerp(100\,110\,t/2)[s1]" -map "[s1]"  -c:v libx264 -t 2 video.mp4 -hide_banner -loglevel debug

At first I thought that all decimals were rounded to integers, but from what I see in the logs it seems that ffmpeg skips frames that contain a fraction of a pixel as a y coordinate (i.e. 100.2).

Here is the generated video & the log file.

Is there a way to generate a smooth effect?

1 Answer 1


ffmpeg does not do sub-pixel overlay. Computed co-ordinates are truncated to integers.

The closest to getting a smooth result is to overlay a large PNG on a large background and then downscale the result to the final resolution i.e. [largebg][largefg]overlay=...,scale=300:250:flags=bicubic

  • do you know if using overlay_cuda (gpu) supports sub-pixels?
    – antoox
    Commented Nov 21, 2023 at 13:07
  • No, it does not.
    – Gyan
    Commented Nov 21, 2023 at 17:44
  • I tried: Scaling by 4, but the result is blurry. Can you think of another way to get the best quality? ffmpeg -y -vsync 0 -f lavfi -i "color=c=white:size=300x250" -f lavfi -i "[email protected]:size=1200x1000,format=yuva420p" -loop 1 -i image.png -filter_complex "[2]scale=228:136[s0];[1][s0]overlay=eof_action=repeat:eval=frame:format=yuv444:x=480:y=lerp(400\,440\,t/2)[s1];[s1]scale=300x250:flags=bicubic[s2];[0][s2]overlay[s3]" -map "[s3]" -c:v libx264 -crf 0 -pix_fmt yuv420p -t 2 video_scale.mp4 -hide_banner
    – antoox
    Commented Nov 21, 2023 at 19:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.