WebRTC:如何为视频编码器启用硬件加速 [英] WebRTC: How to enable hardware acceleration for the video encoder

查看:28
本文介绍了WebRTC:如何为视频编码器启用硬件加速的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在 WebRTC 的帮助下将屏幕截图的视频发送到 mediasoup.WebRTC 库中有一个类:ScreenCapturerAndroid.它有效,但在某些设备上的性能非常糟糕.尤其是当我使用 HD 或更好的显示分辨率时.

在 stackoverflow 上,我发现了一个

从源代码来看,它们确实显示了清晰的信息.

顺便说一下,您也可以在 GooglePlay 中下载一些 Media Codec Info App,以检查不同类型的 android 手机的不同类型的编码器/解码器.这也会有帮助.

I'm trying to send video of screen capture to mediasoup with the help of WebRTC. There is a class for it in the WebRTC library: ScreenCapturerAndroid. It works, but the performance on the some devices is really bad. Especially if I use HD or better display resolutions.

On stackoverflow I've found a suggestion to call setEnableVideoHwAcceleration(true) and setVideoHwAccelerationOptions(). But in the newer versions of WebRTC library the methods have been removed .

Here is my code:

  // ...
PeerConnectionFactory.Builder builder = PeerConnectionFactory.builder();
builder.setOptions(null);

EglBase.Context eglContext = EglUtils.getRootEglBaseContext();

VideoEncoderFactory encoderFactory =
    new DefaultVideoEncoderFactory(
        eglContext, true /* enableIntelVp8Encoder */, true);


PeerConnectionFactory.InitializationOptions initializationOptions =
PeerConnectionFactory.InitializationOptions.builder(context)
//        .setEnableVideoHwAcceleration(true)  // <-- does not work any more 
        .createInitializationOptions();
PeerConnectionFactory.initialize(initializationOptions);

mPeerConnectionFactory =
    builder
        .setVideoEncoderFactory(encoderFactory)
        .createPeerConnectionFactory();

My question is: how can be video hardware acceleration enabled for screen capturing using the newer WebRTC library versions.

解决方案

it's depend on your device and what version of libwebrtc you used. So you can check webrtc source code to know HW support or not. That's mean the hardware acceleration of video encoder will not be support if your libwebrtc don't do some work for it in there source code. :P

So if your libwebrtc don't support it, then cannot see any thing fast even your setting in application level is correct.

So, let talk about how to check hardware acceleration of video encoder in libwebrtc.

Check this source code https://chromium.googlesource.com/external/webrtc/+/HEAD/sdk/android/api/org/webrtc/HardwareVideoEncoderFactory.java

You can search the keyword in HardwareVideoEncoderFactory.java:
"isHardwareSupportedInCurrentSdk"

Today is Jan. 12 and I screen capture the code.

From the source code, they really show clear information.

By the way, you can also download some Media Codec Info App in GooglePlay to check different kind of encoder/decoder for different kind of android phone. That's would be helpful too.

这篇关于WebRTC:如何为视频编码器启用硬件加速的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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