最新消息: 电脑我帮您提供丰富的电脑知识,编程学习,软件下载,win7系统下载。

使用带调色板颜色的ffmpeg将GIF转换为MP4

IT培训 admin 6浏览 0评论

使用带调色板颜色的ffmpeg将GIF转换为MP4

Palettegen还可以:

ffmpeg()
.input('temp/' + input.hash)
.outputOptions(["-vf fps=15,scale=320:-1:flags=lanczos,palettegen"])
.output('temp/palette.png')

使用调色板的转换返回错误:

错误:无法在过滤器Parsed_pa​​letteuse_0上找到未标记输入板1的匹配流

ffmpeg()
.input('color=' + input.bg)
.inputFormat('lavfi')
.input('temp/' + input.hash)
.inputFormat('gif')
.input('temp/palette.png')
.outputOptions('-lavfi paletteuse')
plexFilter(["[0][1]scale2ref[bg][gif]", "[bg]setsar=1[bg]", "[bg][gif]overlay=shortest=1[o]", "[o]scale=trunc(iw/2)*2:trunc(ih/2)*2"])
.outputOptions(['-pix_fmt yuv420p', '-movflags frag_keyframe+empty_moov', '-movflags +faststart', '-crf 5'])
.toFormat('mp4')
.output('temp/final-' + input.hash)

ffmpeg最终命令:

ffmpeg -f lavfi -i color=ffffff -f gif -i temp/cf81f99083462f693406e8fd03ca7009 -i temp/palette.png -y -filter_complex [0][1]scale2ref[bg][gif];[bg]setsar=1[bg];[bg][gif]overlay=shortest=1[o];[o]scale=trunc(iw/2)*2:trunc(ih/2)*2 -lavfi paletteuse -pix_fmt yuv420p -movflags frag_keyframe+empty_moov -movflags +faststart -crf 5 -f mp4 temp/final-cf81f99083462f693406e8fd03ca7009
回答如下:

使用

ffmpeg -f lavfi -i color=ffffff -f gif -i temp/cf81f99083462f693406e8fd03ca7009 -i temp/palette.png -y -filter_complex [0][1]scale2ref[bg][gif];[bg]setsar=1[bg];[bg][gif]overlay=shortest=1,scale=trunc(iw/2)*2:trunc(ih/2)*2[o];[o][2]paletteuse -pix_fmt yuv420p -movflags frag_keyframe+empty_moov+faststart -crf 5 -f mp4 temp/final-cf81f99083462f693406e8fd03ca7009

但请注意,GIF已经调整,并且不需要H264流。

使用带调色板颜色的ffmpeg将GIF转换为MP4

Palettegen还可以:

ffmpeg()
.input('temp/' + input.hash)
.outputOptions(["-vf fps=15,scale=320:-1:flags=lanczos,palettegen"])
.output('temp/palette.png')

使用调色板的转换返回错误:

错误:无法在过滤器Parsed_pa​​letteuse_0上找到未标记输入板1的匹配流

ffmpeg()
.input('color=' + input.bg)
.inputFormat('lavfi')
.input('temp/' + input.hash)
.inputFormat('gif')
.input('temp/palette.png')
.outputOptions('-lavfi paletteuse')
plexFilter(["[0][1]scale2ref[bg][gif]", "[bg]setsar=1[bg]", "[bg][gif]overlay=shortest=1[o]", "[o]scale=trunc(iw/2)*2:trunc(ih/2)*2"])
.outputOptions(['-pix_fmt yuv420p', '-movflags frag_keyframe+empty_moov', '-movflags +faststart', '-crf 5'])
.toFormat('mp4')
.output('temp/final-' + input.hash)

ffmpeg最终命令:

ffmpeg -f lavfi -i color=ffffff -f gif -i temp/cf81f99083462f693406e8fd03ca7009 -i temp/palette.png -y -filter_complex [0][1]scale2ref[bg][gif];[bg]setsar=1[bg];[bg][gif]overlay=shortest=1[o];[o]scale=trunc(iw/2)*2:trunc(ih/2)*2 -lavfi paletteuse -pix_fmt yuv420p -movflags frag_keyframe+empty_moov -movflags +faststart -crf 5 -f mp4 temp/final-cf81f99083462f693406e8fd03ca7009
回答如下:

使用

ffmpeg -f lavfi -i color=ffffff -f gif -i temp/cf81f99083462f693406e8fd03ca7009 -i temp/palette.png -y -filter_complex [0][1]scale2ref[bg][gif];[bg]setsar=1[bg];[bg][gif]overlay=shortest=1,scale=trunc(iw/2)*2:trunc(ih/2)*2[o];[o][2]paletteuse -pix_fmt yuv420p -movflags frag_keyframe+empty_moov+faststart -crf 5 -f mp4 temp/final-cf81f99083462f693406e8fd03ca7009

但请注意,GIF已经调整,并且不需要H264流。

发布评论

评论列表 (0)

  1. 暂无评论