【问题标题】:Serious delay using Huawei MediaCodec decoding H264 rendering TextureView使用华为MediaCodec解码H264渲染TextureView出现严重延迟
【发布时间】:2020-10-19 12:05:40
【问题描述】:

“华为P30使用MediaCodec硬件对H264码流进行解码,然后直接渲染到TextureView显示。”

发现与其他手机平台相比,华为P30的延迟比其他手机多200ms左右。

在配置使用MediaCodec的过程中,发现了一些Native fw层的错误日志,虽然可以正常解码渲染;

执行MediaCodec.configure(****)时报如下错误:

D/SurfaceUtils: connecting to surface 0xc3a99808, reason connectToSurface
I/MediaCodec: [OMX.hisi.video.decoder.avc] setting surface generation to 33448961
D/SurfaceUtils: disconnecting from surface 0xc3a99808, reason connectToSurface(reconnect)
D/SurfaceUtils: connecting to surface 0xc3a99808, reason connectToSurface(reconnect)
E/ACodec: [OMX.hisi.video.decoder.avc] setPortMode on output to DynamicANWBuffer failed w/ err -2147483648
I/ACodec: [OMX.hisi.video.decoder.avc] got color aspects (R:2(Limited), P:1(BT709_5), M:1(BT709_5), T:3(SMPTE170M)) err=0 (NO_ERROR)
I/ACodec: [OMX.hisi.video.decoder.avc] got color aspects (R:2(Limited), P:1(BT709_5), M:1(BT709_5), T:3(SMPTE170M)) err=0 (NO_ERROR)
I/ACodec: [OMX.hisi.video.decoder.avc] using color aspects (R:2(Limited), P:1(BT709_5), M:1(BT709_5), T:3(SMPTE170M)) and dataspace 0x104

解码过程中出现如下警告:

I/ACodec: [OMX.hisi.video.decoder.avc] got color aspects (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) err=0 (NO_ERROR)
I/ACodec: [OMX.hisi.video.decoder.avc] got color aspects (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) err=0 (NO_ERROR)
I/ACodec: [OMX.hisi.video.decoder.avc] using color aspects (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) and dataspace 0x102
I/ACodec: [OMX.hisi.video.decoder.avc] got color aspects (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) err=0 (NO_ERROR)
I/ACodec: [OMX.hisi.video.decoder.avc] got color aspects (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) err=0 (NO_ERROR)
I/ACodec: [OMX.hisi.video.decoder.avc] using color aspects (R:2(Limited), P:3(BT601_6_625), M:3(BT601_6), T:3(SMPTE170M)) and dataspace 0x102
D/SurfaceUtils: disconnecting from surface 0xc3a99808, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils: connecting to surface 0xc3a99808, reason setNativeWindowSizeFormatAndUsage
D/SurfaceUtils: set up nativeWindow 0xc3a99808 for 720x1280, color 0x30d, rotation 0, usage 0X20002900
W/ACodec: [OMX.hisi.video.decoder.avc] setting nBufferCountActual to 11 failed: -2147483648"

【问题讨论】:

  • 你能把你的问题说得更清楚吗?您需要帮助解决错误消息吗?
  • 缓冲区数量是否设置错误?
  • 基本语法和拼写编辑

标签: decode android-mediacodec huawei-mobile-services huawei-developers


【解决方案1】:

这些日志与延迟无关。如果OMX.hisi.video.decoder.avc硬件解码器部分配置不支持,会打印日志,方便故障定位。

(比如粗体的DynawBuffer为端口配置,不支持则使用其他端口模式,不影响解码。)

200ms的延迟不知道怎么计算,可以分为H.264视频解码时间和渲染到TextureView的时间。

要获取解码延迟,可以通过在输入解码数据和得到解码输出时添加log来获取具体的时间差。 对比其他手机的时差,进一步分析时差。

此外,解码器和纹理配置(例如分辨率和帧速率)也会影响性能。 或者,您可以为研发工程师提供一种方法来重现问题以进行分析。

感谢您的支持!

【讨论】:

    猜你喜欢
    • 2021-08-30
    • 2015-12-26
    • 2016-05-27
    • 1970-01-01
    • 2018-10-17
    • 2017-06-30
    • 2020-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多