使用 FFmpeg 在图像上连续播放 gif



我正在尝试在图像上放置多个 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输入选项并将shortest=1选项添加到任何具有无限循环 GIF 作为输入的叠加层中。

简化示例:

ffmpeg -i video.mp4 -stream_loop -1 -i 1.gif -filter_complex "overlay=shortest=1:format=auto" output.mp4

要避免黄线,请添加调色板生成和调色板使用过滤器:

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

最新更新