我正在尝试将ffmpeg的某些图像转换为带有淡入淡出效果的gif动画。
我已经以该网页为例来说明自己要执行的操作:
我在这里分享
这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
但是我没有得到预期的结果。
有人可以帮我吗?
谢谢