我一直在研究 gstreamer applemedia encoder plugins并改进了基于 VideoToolbox 的视频编码。像这样运行 gstreamer 管道:
$ gst-launch-1.0 filesrc location=source.avi ! decodebin ! vtenc_h264 ! h264parse ! qtmux name=mux ! filesink location=sink.mp4
在 Mac OS 系统上使用 VTCompressionSession
编码 h264 视频时,我期望看到非常低的 CPU 使用率。但是,在我测试过的系统上:配备 GeForce 9600M 的 2009 年中期 Macbook Pro 和配备 Radeon HD 6630M 的 2011 年中期 Mac mini,编码仍然消耗 80% 到 130% 的 CPU - 这表明它没有硬件加速。
VTCompressionSession
在哪些硬件配置上,或给定哪些压缩参数(例如,针对哪个 kVTCompressionPropertyKey_ProfileLevel
)使用硬件加速编码?
最佳答案
根据 http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/applemedia/vtenc.c您将 NULL 传递给 encoderSpecification 参数的 VTCompressionSessionCreate()。创建一个编码器规范字典,将 kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder 设置为 kCFBooleanTrue。
关于macos - VideoToolbox 的 VTCompressionSession 何时受益于硬件加速?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19256897/