1

i am trying to add gif and text on video using ffmpeg somewhat similar to tiktok. want it to be like tiktok ie on top right gif and text and after sometime left bottom same gif and text on the video.

3 Answers3

0
ffmpeg -i video.mp4 -ignore_loop 0 -i logo.gif -filter_complex "[0:v][1:v]overlay=x=10:y=10:format=auto:enable='lte(t,5)':shortest=1[bg];[bg][1:v]overlay=x=main_w-overlay_w-10:y=main_h-overlay_h-20:format=auto:enable='gte(t,5)':shortest=1,drawtext=text='@user1872811':fontsize=16:fontcolor=white:x=10:y=40:enable='lte(t,5)',drawtext=text='@user1872811':fontsize=16:fontcolor=white:x=w-tw-10:y=h-th-10:enable='gte(t,5)',format=yuv420p[v]" -map "[v]" -c:v libx264 -crf 18 -map 0:a -c:a copy -movflags +faststart output.mp4

You will need to adjust x and y positions for overlay and drawtext depending on the GIF width x height.

Adapted from:

Also see:

llogan
  • 121,796
  • 28
  • 232
  • 243
0

Top-Left To Bottom-Right loop:

ffmpeg -i video.mp4 -i watermark.png -filter_complex \
 "[0:v][1:v]overlay=x='if(lt(mod(t,10),5),10,W-w-10)':y='if(lt(mod(t,10),5),10,H-h-10)'" \
 -codec:a copy out.mp4

Top-Right To Bottom-Left loop:

ffmpeg -i video.mp4 -i watermark.png -filter_complex \
 "[0:v][1:v]overlay=x='if(lt(mod(t,10),5),W-w-10,10)':y='if(lt(mod(t,10),5),10,H-h-10)'" \ 
 -codec:a copy out.mp4

Idea is very simple

  • Take every 10sec duration, get remainder sec i.e. mod(t,10)
  • if sec < 5, set top position else bottom position

Please note I have excluded text i.e. username.

-1

ffmpeg -y -i out.mp4 -i 1080_Happy_Holidays_Red_Videvo.mov -i logo.png -filter_complex "[0]scale=iw/4:-1[pip];[1][pip]overlay=100:100[watermark];[watermark][2]overlay=main_w-overlay_w-10:main_h-overlay_h-10" output.mp4

You have more examples on my webste but it is forbiddien to give here an URL. Send me a private message

Seb
  • 65
  • 1
  • 6