【问题标题】:How can I use libx265 (H.265) in the ffmpeg-python package?如何在 ffmpeg-python 包中使用 libx265 (H.265)?
【发布时间】:2021-09-03 22:13:36
【问题描述】:

如何在 ffmpeg-python 包中使用 libx265 (H.265)?

我尝试使用:

(
    ffmpeg
    .input('0.mp4')
    .filter('fps', fps=25, round='up')
    .output('out.mkv', format='h265')
    .run()
)

但是它抛出了一个错误:

格式无法识别

但这有效:

(
    ffmpeg
    .input('0.mp4')
    .filter('fps', fps=25, round='up')
    .output('out.mkv', format='h264')
    .run()
)

【问题讨论】:

标签: python video ffmpeg video-conversion


【解决方案1】:

format='h265' 替换为vcodec='libx265'


  • H.265 是一种视频编解码器,vcodec='libx265' 告诉 FFmpeg 使用libx265 视频编码器。
  • 如果是 MKV 视频容器,输出格式为format='matroska'。 您不必设置格式,因为 FFmpeg 会自动通过 .mkv 文件扩展名选择输出格式。

更新代码:

import ffmpeg

(
    ffmpeg
    .input('0.mp4')
    .filter('fps', fps=25, round='up')
    .output('out.mkv', vcodec='libx265')
    .run()
)

【讨论】:

  • 谢谢!是否可以在上面的代码中添加“-bitexact -map_metadata -1”?
  • 您可以将它们添加到输出参数中:output('out.mkv', vcodec='libx265', fflags='bitexact', map_metadata='-1')
  • 看起来fflags='bitexact' 不等于-bitexact。一种解决方法是使用**{'bitexact': None}(而不是fflags='bitexact')。
猜你喜欢
  • 2015-07-19
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-08-19
相关资源
最近更新 更多