<p>I would like to apply a .png on two frames of my input video but
I'm having trouble using an if statement to determine the location of the overlay.</p>
<p><strong>Expected:</strong> <br />
Frame n°7 -&gt; Frame n°7 + overlay.png with pos(300,700) <br />
Frame n°12 -&gt; Frame n°12 + overlay.png with pos(0,0) <br />
Frame n°?? -&gt; Frame n°??</p>
<p>Here is the ffmpeg command found on this post with similar use-cases: <a href="https://video.stackexchange.com/questions/24330/how-to-have-an-overlay-move-to-specific-points-at-specific-frames-using-ffmpeg">How to have an overlay move to specific points at specific frames using ffmpeg</a></p>
<pre><code>ffmpeg -i input.mkv -i overlay.png -filter_complex &quot;[0:v][1:v]overlay=x='if(eq(n,7),300,0)':y='if(eq(n,7),700,0)':enable='eq(n,7)+eq(n,12)'[out]&quot; -map [out] output.mkv
</code></pre>
<p>But in my case, the if condition <code>x='if(eq(n,7),300,0)'</code> and <code>y='if(eq(n,7),700,0)'</code> always return false and I do not understand why this is happening.</p>
<p>Thanks!</p>

CC BY-SA 4.0
2024-05-03T12:59:55.153Z
`...:enable='eq(n,6...` in x y → n starts from 1? in enable → n starts from 0?
Баяр Гончикжапов
CC BY-SA 4.0
2024-05-03T13:21:22.147Z
@БаярГончикжапов
It works! Thank you very much!
legeba
<ffmpeg><video>
ffmpeg - Trouble using if statement with overlay
legeba
# ffmpeg - Trouble using if statement with overlay

(Asked by: username_0 on 2024-05-03)

I would like to apply a .png on two frames of my input video but
I'm having trouble using an if statement to determine the location of the overlay.
Expected: 
Frame n°7 -> Frame n°7 + overlay.png with pos(300,700) 
Frame n°12 -> Frame n°12 + overlay.png with pos(0,0) 
Frame n°?? -> Frame n°??
Here is the ffmpeg command found on this post with similar use-cases: How to have an overlay move to specific points at specific frames using ffmpeg
ffmpeg -i input.mkv -i overlay.png -filter_complex "[0:v][1:v]overlay=x='if(eq(n,7),300,0)':y='if(eq(n,7),700,0)':enable='eq(n,7)+eq(n,12)'[out]" -map [out] output.mkv

But in my case, the if condition x='if(eq(n,7),300,0)' and y='if(eq(n,7),700,0)' always return false and I do not understand why this is happening.
Thanks!

**Tags:** ffmpeg, video

> **Comments:**
> **username_1**: `...:enable='eq(n,6...` in x y → n starts from 1? in enable → n starts from 0?  
> **username_0**: @БаярГончикжапов It works! Thank you very much!  

---

## 0 answers

