[英]How to load GIF continuously on video in android using FFMPEG?
[英]Continuously play the gif on image using FFmpeg
我正在嘗試在圖像上放置多個 gif 並使用 FFmpeg 保存為 gif。 我已經實現了多個 gif 的放置,但所有 gif 都不會連續播放,即第二個 gif 只重復一次第一個 gif 完成並再次開始..第二個 gif 僅在第一個 gif 完成時停止並重新開始。
command_try[0]="-i";
command_try[1]=input;
command_try[2]="-i";
command_try[3]=gifthumbnail;
command_try[4]="-i";
command_try[5]=gifthumbnail;
command_try[6]="-i";
command_try[7]=thumbnail;
command_try[8]="-i";
command_try[9]=thumbnail2;
command_try[10]="-filter_complex";
command_try[11]="[0:v]scale=0:0[base];[1:v]scale=300:-1[img1];[2:v]scale=720:-1290[img2];[3:v]scale=80:-1[img3];[4:v]scale=50:-1[img4];[img1]rotate=45:c=black@0:ow=rotw(45):oh=roth(45)[r1];[img2]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[r2];" +
"[img3]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[r3];[img4]rotate=0:c=black@0:ow=rotw(0):oh=roth(0)[r4];[base][r1]overlay=100:70[tmp1];"+
"[tmp1][r2]overlay=55:55[tmp2];[tmp2][r3]overlay=65:65[tmp3];[tmp3][r4]overlay=30:30";
command_try[12]="-preset";
command_try[13]="veryfast";
command_try[14]="/storage/emulated/0/Pictures/imggif.gif";
由於我最近開始研究 FFmpeg,因此需要幫助才能獨立連續播放 gif。
使用-stream_loop -1
輸入選項並將-stream_loop -1
shortest=1
選項添加到任何以無限循環 GIF 作為輸入的疊加層。
簡化示例:
ffmpeg -i video.mp4 -stream_loop -1 -i 1.gif -filter_complex "overlay=shortest=1:format=auto" output.mp4
為了避免出現黃線,添加palettegen和paletteuse過濾器:
ffmpeg -i video.mp4 -stream_loop -1 -i 1.gif -filter_complex "overlay=shortest=1:format=auto,split[s0][s1];[s0]palettegen[p];[s1][p]paletteuse" output.gif
您使用的是非常舊的 FFmpeg 3.0.1,因此您必須將auto
更改為rgb
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.