此命令对于某些GIF效果很好,但对于其他一些GIF返回错误:
ffmpeg -f gif -f lavfi -i color=FFFFFF -i animated.gif -y
-filter_complex "[0][1]scale2ref[bg][gif];[bg]setsar=1[bg];[bg][gif]overlay=shortest=1"
-pix_fmt yuv420p -movflags frag_keyframe+empty_moov -movflags +faststart
-crf 20 -b:v 500k -f mp4 animated.mp4
错误:
[libx264 @ 0x55e79dc7e3c0] height not divisible by 2 (1400x933)
Error initializing output stream 0:0 -- Error while opening encoder for output stream #0:0
- maybe incorrect parameters such as bit_rate, rate, width or height
要解决一些问题,以保持背景颜色功能?
答案 0 :(得分:1)
使用
ffmpeg -f gif -f lavfi -i color=FFFFFF -i animated.gif -y
-filter_complex "[0][1]scale2ref[bg][gif];[bg]setsar=1[bg];[bg][gif]overlay=shortest=1,scale=w='2*trunc(iw/2)':h='2*trunc(ih/2)'"
-pix_fmt yuv420p -movflags frag_keyframe+empty_moov -movflags +faststart
-crf 20 -b:v 500k -f mp4 animated.mp4
对于yuv420p
输入,x264要求宽度和高度均为偶数。