Muhammad Sanaullah
Muhammad Sanaullah

Reputation: 455

Adding GIF as Watermark and Loop FFMPEG

I try to add GIF over a video and continuously loop, but it animate once and stop on the video

ffmpeg.exe -i "video.mp4" -i "ani.gif" -filter_complex "[1:v]format=yuva444p,setsar=1,scale=80:80,rotate=PI/6:c=black@0:ow=rotw(PI/6):oh=roth(PI/6) [rotate];[0:v][rotate] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2" -codec:a copy -y output.mp4

What is the solution?

Thanks,

Upvotes: 2

Views: 4731

Answers (1)

Gyan
Gyan

Reputation: 93271

Use

ffmpeg.exe -i "video.mp4" -ignore_loop 0 -i "ani.gif" -filter_complex "[1:v]format=yuva444p,scale=80:80,setsar=1,rotate=PI/6:c=black@0:ow=rotw(PI/6):oh=roth(PI/6) [rotate];[0:v][rotate] overlay=(main_w-overlay_w)/2:(main_h-overlay_h)/2:shortest=1" -codec:a copy -y output.mp4

ignore_loop makes the GIF to loop as many times as set in the file's header, usually infinite.

The overlay normally runs till the end of both inputs, but that won't work here as the GIF will be looping indefinitely, so shortest option is enabled.

Upvotes: 6

Related Questions