![是否可以让 FFmpeg 在 macOS 上使用硬件加速进行 HEVC 转码?](https://linux22.com/image/1553799/%E6%98%AF%E5%90%A6%E5%8F%AF%E4%BB%A5%E8%AE%A9%20FFmpeg%20%E5%9C%A8%20macOS%20%E4%B8%8A%E4%BD%BF%E7%94%A8%E7%A1%AC%E4%BB%B6%E5%8A%A0%E9%80%9F%E8%BF%9B%E8%A1%8C%20HEVC%20%E8%BD%AC%E7%A0%81%EF%BC%9F.png)
我有一台 MacBook Pro,配备 Kaby Lake 处理器,运行 macOS High Sierra (10.12)。是否可以通过某种方式设置 FFmpeg 以使用工具箱进行 HEVC 硬件编码,而不是 libx265?
答案1
在 MacOSX 上,有一个 Videotoolbox,这是一个低级框架,可以直接访问硬件编码器和解码器。它提供视频压缩和解压缩服务,以及存储在核心视频像素缓冲区。这些服务以会话对象(压缩、解压缩和像素传输)的形式提供,以核心基础 (CF) 类型。
FFmpeg 在硬件环境中(用于硬件加速启动)和编码器包装器(用于转码支持的编解码器)实现 Videotoolbox。
查看hevc_videotoolbox
编码器包装器的私有编码器选项:
ffmpeg -hide_banner -h encoder=hevc_videotoolbox
输出:
Supported pixel formats: videotoolbox_vld nv12 yuv420p
hevc_videotoolbox AVOptions:
-profile <int> E..V.... Profile (from 0 to 3) (default 0)
main E..V.... Main Profile
main10 E..V.... Main10 Profile
-allow_sw <boolean> E..V.... Allow software encoding (default false)
-realtime <boolean> E..V.... Hint that encoding should happen in real-time if not faster (e.g. capturing from camera). (default false)
-frames_before <boolean> E..V.... Other frames will come before the frames in this session. This helps smooth concatenation issues. (default false)
-frames_after <boolean> E..V.... Other frames will come after the frames in this session. This helps smooth concatenation issues. (default false)
请注意,随着较新的 ffmpeg 版本中暴露更多功能,输出可能会随着时间的推移而发生变化。
如果您有最新的 Mac,也许您可以用它来测试一下。
如您所见,它利用了 macOS 上可用的基于硬件的编码器,为跨多个供应商特定抽象的视频编码提供统一的 API,范围从英特尔(快速同步) 和 AMD GPU(上一代维多利亚州教育委员会和当前一代虚拟专用网络x86 上的 SIP 块),包括最新的Apple Silicon 的 M 系列ARM SoC。
在这里获取构建:https://evermeet.cx/ffmpeg/
答案2
不确定自 OP 的评论以来这是否有所改变,但在 FFmpeg 4.x 中,命令是:
ffmpeg -hide_banner -h encoder=hevc_videotoolbox