Ana Koridze
Ana Koridze

Reputation: 1777

add multiple overlays to a single image with ffmpeg

How am I supposed to add two transition animations to the same image in the video with ffmpeg command? I want the image to slide from left to right and after a while back from right to left... This command is for left to right

ffmpeg -i input.mp4 -i image.png -filter_complex "[0:v][1:v]overlay=x='min(-1.5*w+5*w*t,5)':y=H/2-h/2'" -y output.mp4

Upvotes: 0

Views: 1082

Answers (1)

Gyan
Gyan

Reputation: 92928

There are two methods to do this. One is to provide a clipped oscillating function, similar to the expression for x used in the drawtext filter here.

The other method is use a conditional expression, shown below.

ffmpeg -i input.mp4 -i image.png
  -filter_complex
     "[0:v][1:v]overlay=x='if(lt(t,8),min(-1.5*w+5*w*t,5),5-5*w*(t-8))':y=H/2-h/2'"
  -y output.mp4

Here's the slide out starts at t=8s.

Upvotes: 1

Related Questions