【问题标题】:Convert GIF to MP4 with ffmpeg with palette color使用带有调色板颜色的 ffmpeg 将 GIF 转换为 MP4
【发布时间】:2019-03-28 15:52:57
【问题描述】:

调色板没问题:

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')
.complexFilter(["[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

【问题讨论】:

    标签: node.js ffmpeg fluent-ffmpeg


    【解决方案1】:

    使用

    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 流不需要。

    【讨论】:

      猜你喜欢
      • 2020-03-30
      • 1970-01-01
      • 1970-01-01
      • 2020-03-31
      • 1970-01-01
      • 2016-09-30
      • 1970-01-01
      • 2021-06-30
      • 2019-02-08
      相关资源
      最近更新 更多