Answers.Body: <p>ffmpeg does not do sub-pixel overlay. Computed co-ordinates are truncated to integers.</p>
  <p>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. <code>[largebg][largefg]overlay=...,scale=300:250:flags=bicubic</code></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-21T13:07:28.023Z
Answers.Text: do you know if using `overlay_cuda` (gpu) supports sub-pixels?
Answers.UserDisplayName: antoox
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-21T17:44:41.757Z
Answers.Text: No, it does not.
Answers.UserDisplayName: Gyan
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-21T19:22:08.623Z
Answers.Text: 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 "color=color=black@0.0: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```
Answers.UserDisplayName: antoox
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-11-21T04:53:57.913Z
Answers.LastActivityDate: 2023-11-21T04:53:57.913Z
Answers.UserDisplayName: Gyan
Body: <p>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.</p>
  <p>Here is the command I am using:</p>
  <pre><code>ffmpeg -y -vsync passthrough -f lavfi -i color=c=white:size=300x250 -loop 1 -framerate 25 -i image.png -filter_complex &quot;[0][1]overlay=eval=frame:format=yuv444:x=120:y=lerp(100\,110\,t/2)[s1]&quot; -map &quot;[s1]&quot;  -c:v libx264 -t 2 video.mp4 -hide_banner -loglevel debug
  </code></pre>
  <p>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 <code>y</code> coordinate <em>(i.e. 100.2)</em>.</p>
  <p>Here is the <a href="https://local-banners.s3.eu-west-1.amazonaws.com/video/video.mp4" rel="nofollow noreferrer">generated video</a> &amp; <a href="https://local-banners.s3.eu-west-1.amazonaws.com/video/log.txt" rel="nofollow noreferrer">the log file.</a></p>
  <p>Is there a way to generate a smooth effect?</p>
  
Tags: <ffmpeg><effects>
Title: ffmpeg - Prevent ffmpeg to skip frames
UserDisplayName: antoox
ThreadText: # ffmpeg - Prevent ffmpeg to skip frames
  
  (Asked by: username_0 on 2023-11-20)
  
  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](https://local-banners.s3.eu-west-1.amazonaws.com/video/video.mp4) & [the log file.](https://local-banners.s3.eu-west-1.amazonaws.com/video/log.txt)
  
  Is there a way to generate a smooth effect?
  
  **Tags:** ffmpeg, effects
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2023-11-21. Score: 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`
  
  > **Comments:**
  > **username_0**: do you know if using `overlay_cuda` (gpu) supports sub-pixels?  
  > **username_1**: No, it does not.  
  > **username_0**: 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 "color=color=black@0.0: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```  
  
  ---
  
  