具体方法
# Simple conversion to animated gif.
# 简单gif转换
ffmpeg -hide_banner -nostdin -y -i VIDEO.mkv OUTPUT.gif
# Conversion to animated gif using palette colors.
# 生成带有预览图的gif
# 1 - Export the palette colors.
# 1 - 导出预览图
ffmpeg -y -i VIDEO.mkv -vf fps=10,palettegen palette.png
# 2 - Output the GIF using the palette.
# 2 - 添加预览图导出gif
ffmpeg -y -i VIDEO.mkv -i palette.png -filter_complex "fps=10" OUTPUT.gif
# If you want higher quality, use the followings:
# 高质量gif生成方法
ffmpeg -y -i VIDEO.mkv \
-vf fps=10,scale=0:-1:flags=lanczos,palettegen palette.png
ffmpeg -y -i VIDEO.mkv -i palette.png -filter_complex \
"fps=10,scale=0:-1:flags=lanczos[x];[x][1:v]paletteuse" OUTPUT.gif