Media Foundation h264编码器性能不佳 [英] Media Foundation h264 encoder poor performance

查看:552
本文介绍了Media Foundation h264编码器性能不佳的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Media Foundation h264编码器性能不佳

Media Foundation h264 encoder poor performance

我正在编写一个实时记录PC屏幕并使用Media Foundation h264编解码器对其进行编码的应用程序. 编码会消耗大量CPU资源.在我停止录制视频(或通过简单地停止向编码器提供视频和音频帧来暂停它)之后,CPU负载会长时间保持很高的状态(5-10秒或更长时间).在这段时间内,应用程序会等到IMFSinkWriter :: Finalize方法完成.

I'm writing an application which records PC's screen in realtime and encodes it with Media Foundation h264 codec. Encoding consumes a lot of CPU resources. And after I stop recording video (or pause it by simply stopping feeding an encoder with video and audio frames), CPU load stays very high for a long period of time (5-10 seconds and more). During this time application waits until IMFSinkWriter::Finalize method completes.

我的电脑配置:

  • 具有4核的Intel i5-2410M 2.3 GHz
  • 8 GB RAM

编解码器配置:

  • 25 fps
  • 1364 x 768分辨率
  • 基准资料
  • 1.2 MBit比特率

这是MF h264编解码器性能的限制吗,还是由于我的代码中的错误/配置错误?

Is this a limitation of MF h264 codec performance or is it due to bugs/misconfiguration in my code?

推荐答案

内部队列很长的管道在对视频进行编码直到队列为空之前,这是预期的行为.由于-似乎-使用了软件编码器,而且速度很慢,因此您的屏幕捕获源会生成足够的数据来填满队列,从而使队列变得很紧,以至于需要花费额外的时间来整理出来.

It is expected behavior for the pipeline having a long internal queue to keep encoding video until the queue is empty. Since - as it seems - software encoder is being used and it's pretty slow, your screen capture source generates enough data to fill the queues so tight that it takes additional seconds to sort that out.

您的解决方案是控制/降低数据速率,或者使用更快的速度,尤其是.硬件辅助的编码器.但是,Media Foundation可以自动利用硬件编码器,因此我认为这不是您的选择.您可以使用 MediaFoundationVideoEncoderTransforms工具检查硬件编码器的可用性.

Your solution would be to either control/reduce data rate, or use faster, esp. hardware-assisted, encoder. Media Foundation could however take advantage of hardware encoders automatically so I suppose it's not the option for you. You can check availability of hardware encoders using MediaFoundationVideoEncoderTransforms tool.

这篇关于Media Foundation h264编码器性能不佳的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆