1

I used somebody else's code posted by LordNeckbeard here: FFmpeg move overlay from one pixel coordinate to another

I modified it a bit to this:

    ffmpeg -i 4632.mpg -i 4632.bmp -filter_complex "[0]scale=320:240[over];
    [1][over]overlay=enable='between=(t,0,50)':x=20+t*30:y=20+t*20" -s 
    1280:720 -c:a copy -y output.mpg

I'd like to be able to limit the movement so the overlay does not go off screen. How can I move a scaled clip overlay in four directions, X & Y starting from originating location and back?

techr
  • 11
  • 4

1 Answers1

4

This step-wise motion has to be constructed using a union of conditional expressions. Basic syntax of each unit is

(origin + (destination - origin)*(t - start time)/duration) * between(t,start time,end time)

Then all units are added together, like in the example below.

Let's say you want to move the clip from (ax,ay) to (bx,by) to (cx,cy) and back to (ax,ay). Let's keep each leg to 10 seconds.

Syntax is overlay=x='(ax+(bx-ax)*(t-0)/10)*between(t,0,10)+(bx+(cx-bx)*(t-10)/10)*between(t,10,20)+(cx+(ax-cx)*(t-20)/10)*between(t,20,30)':y='(ay+(by-ay)*(t-0)/10)*between(t,0,10)+(by+(cy-by)*(t-10)/10)*between(t,10,20)+(cy+(ay-cy)*(t-20)/10)*between(t,20,30)'

Gyan
  • 85,394
  • 9
  • 169
  • 201
  • How can I smooth out the movement? I'm looking at a similar effect done on adobe premiere and the animation moves smoothly compared to ffmpeg result. – techr Aug 31 '17 at 15:47
  • Share the Premiere video. – Gyan Aug 31 '17 at 15:50
  • I uploaded it on youtube but I have to make it private since it's work related. What email can I share it with or how can I share it to you only? – techr Aug 31 '17 at 17:14
  • BTW - I tried this example you gave on another post but I have to add it in the -filter_complex statement at the very end: [out]minterpolate=60,tblend=all_mode=average,framestep=2 but didn't see a difference – techr Aug 31 '17 at 17:23
  • "This video is unavailable" – Gyan Aug 31 '17 at 19:36
  • I need an email to share a private video. Unfortunately, I can't make it public. – techr Aug 31 '17 at 21:20
  • Please let me know if you got the notification. – techr Sep 01 '17 at 15:40