ffmpeg使用淡入淡出框架将png和jpg转换为动画gif

时间:2019-06-08 09:12:04

标签: ffmpeg fade animated-gif

我正在尝试将ffmpeg的某些图像转换为带有淡入淡出效果的gif动画。

我已经以该网页为例来说明自己要执行的操作:

https://ezgif.com/maker

我在这里分享

https://wetransfer.com/downloads/a28b8405e86a6d2bf355ea997dcccc0220190608090244/7461f8a6cf8c27be629527152f2a491a20190608090244/d7dae9?utm_campaign=WT_email_tracking&utm_content=general&utm_medium=download_button&utm_source=notify_recipient_email

这5张图片(1.png,2.jpg,3.jpg,4.jpg,5.jpg)和结果来自ezgif(result.gif)

我尝试使用:

https://superuser.com/questions/1002562/convert-multiple-images-to-a-gif-with-cross-dissolve

创建调色板

 ffmpeg \
 -loop 1 -t 1 -i 1.png \
 -loop 1 -t 1 -i 2.jpg \
 -loop 1 -t 1 -i 3.jpg \
 -loop 1 -t 1 -i 4.jpg \
 -loop 1 -t 1 -i 5.jpg \
 -filter_complex \
 "[1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v]; \
  [2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v]; \
  [3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v]; \
  [4:v][3:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b4v]; \
  [0:v][b1v][1:v][b2v][2:v][b3v][3:v][b4v]     [4:v]concat=n=9:v=1:a=0,fps=10,scale=320:-1:flags=lanczos,palettegen[v]" \
 -map "[v]" palette.png

然后获取输出

 ffmpeg -loop 1 -t 1 -i 1.png -loop 1 -t 1 -i 2.jpg -loop 1 -t 1 -i 3.jpg -loop 1 -t 1 -i 4.jpg -loop 1 -t 1 -i 5.jpg \ -i palette.png \
 -filter_complex \
 "[1:v][0:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b1v]; \
  [2:v][1:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b2v]; \
  [3:v][2:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b3v]; \
  [4:v][3:v]blend=all_expr='A*(if(gte(T,0.5),1,T/0.5))+B*(1-(if(gte(T,0.5),1,T/0.5)))'[b4v]; \
  [0:v][b1v][1:v][b2v][2:v][b3v][3:v][b4v]    [4:v]concat=n=9:v=1:a=0,fps=10,scale=320:-1:flags=lanczos[c];[c]     [5:v]paletteuse[v]" \
 -map "[v]" out.gif

但是我没有得到预期的结果。

有人可以帮我吗?

谢谢

0 个答案:

没有答案