rtp2httpd icon indicating copy to clipboard operation
rtp2httpd copied to clipboard

Web

Open gdwengf opened this issue 1 month ago • 5 comments

gdwengf avatar Oct 25 '26 05:10 gdwengf

更正:根因不在 SoC 解码器,在浏览器解码路径

补充一个推翻我自己上文推断的对照实验(同一台设备、同一 URL、同一播放器页面):

浏览器 结果
华为自带浏览器 正常播放
狐猴浏览器(Lemur,Chromium 内核) 黑屏,一帧不出

也就是说这台麒麟手机的硬件解码器是能解这些流的,我上文「POC type 0 + 场编码触发海思解码器限制」的判断是错的,抱歉。

真正的差异在浏览器的 H.264 解码路径:Chromium 有严格的 FFmpeg codec 白名单(StrictFFmpegCodecs),#671 里您提到过同类情况——某些隔行 H.264 流在 Chrome 上被拒,需要 --disable-features=StrictFFmpegCodecs 才能播。华为自带浏览器走自家内核 / 系统解码器直通,没有这层白名单,所以正常。

上文的 SPS 差异仍然是客观事实(能播组 pic_order_cnt_type=2;不能播组 pic_order_cnt_type=0 + bottom_field_pic_order_in_frame_present=1 + 场编码,其余参数相同),但它解释的是「为什么这批流会被严格白名单拒」,不是设备解码能力。

想继续请教

  1. 狐猴这类第三方 Chromium 是否就是命中 StrictFFmpegCodecs?手机上没有启动参数可加,播放器侧有没有办法绕(比如换一种 codec 能力声明、或直接走软解)?
  2. Web Player 能否在解码失败时给出可见错误(如「本浏览器不支持该编码」),而不是纯黑屏?对排查这类问题帮助很大。

谢谢。

gdwengf avatar Oct 25 '26 07:10 gdwengf

Additional findings: cross-device / cross-browser comparison

Same URL, same player page, four combinations tested:

Device Browser Result
Huawei Kirin (HarmonyOS) Huawei Browser works
Huawei Kirin Lemur Browser (Chromium) fails
Huawei Kirin Android WebView fails
Snapdragon tablet Android WebView works

These results suggest the problem is not specific to Lemur Browser, and is not simply a lack of H.264 hardware decoding support — the Huawei Browser decodes the same stream fine on the same SoC.

A possible explanation is an incompatibility between Chromium's Android media pipeline and the Huawei/Kirin MediaCodec implementation, including codec capability detection, decoder initialization, or H.264 bitstream handling.

The StrictFFmpegCodecs hypothesis remains unconfirmed (the Huawei Browser is not Chromium-based, so the comparison above does not isolate that feature).

Could the developers investigate the MediaCodec decoder selection and initialization behavior on Huawei/Kirin devices? I can provide sample TS segments and any logs (logcat / media-internals equivalent) that would help.

gdwengf avatar Oct 25 '26 08:10 gdwengf

media-internals from the failing device (Kirin)

Captured chrome://media-internals on the Kirin device while playing a failing channel and a working one.

Common to both — the video decoder is the platform OMX decoder, not software:

kVideoDecoderName    = MediaCodecVideoDecoder
kIsPlatformVideoDecoder = true
info:    Created MediaCodec OMX.hisi.video.decoder.avc, is_software_codec=0
warning: Unable to lookup coded size alignment for codec OMX.hisi.video.decoder.avc
debug:   Video rendering in low delay mode.

Working channel (CCTV-2, same player page, same device) — reaches kPlaying and stays there; only repeated debug: Prepared video sample is not conformant, no error. H.264 high, 1920x1080, decoded by OMX.hisi.video.decoder.avc.

Failing channel — ~100 ms after the OMX decoder is created:

warning: video decoder fallback after initial decode error.
info:    Cannot select VpxVideoDecoder for video decoding
info:    Cannot select Dav1dVideoDecoder for video decoding
error:   PipelineStatus code=3  (PIPELINE_ERROR_DECODE)
         cause: DecoderStatus code=1
         media/gpu/android/media_codec_video_decoder.cc:824
         media/renderers/video_renderer_impl.cc:592
→ playerState = errored (black screen)

The same happens on every retry (player 42:0 … 42:7 all fail identically), and with Android WebView too.

So on this device Chromium does select the Kirin hardware decoder and the failure is an initial decode error inside the MediaCodec path — not a missing codec, and not StrictFFmpegCodecs. The Huawei browser decodes the exact same stream on the same SoC, so the hardware itself is capable.

Two things in the log look suspicious and I'd like your read on them:

  1. Unable to lookup coded size alignment for codec OMX.hisi.video.decoder.avc — Chromium couldn't obtain stride / slice-height alignment from this OMX component. Could it be handing this decoder buffers with wrong alignment/size for this particular stream?
  2. The working channels are pic_order_cnt_type=2; the failing ones are field-coded (frame_mbs_only_flag=0, PAFF, pic_order_cnt_type=0 + bottom_field_pic_order_in_frame_present=1). Could the MediaCodec path mishandle field-coded H.264 on this decoder (e.g. expects frame-mode slices / specific slice ordering)?

Is there anything we can test from the player side — e.g. requesting a specific color format, surface vs byte-buffer output, or a different codec/profile string — that would tell us whether this is a Chromium-side configuration issue rather than a driver limitation?

I can provide the full media-internals export and sample TS segments if useful.

gdwengf avatar Oct 25 '26 08:10 gdwengf

One correction to my previous comment, after re-reading the full export:

The warning Unable to lookup coded size alignment for codec OMX.hisi.video.decoder.avc also appears on the working CCTV-2 playback on the same device, right after its decoder is created — so it is not the differentiator, and has extra data: false is identical on both as well. Please disregard point 1 in my previous message.

The only reproducible difference between working and failing channels remains:

  • working (CCTV-2): decoder created → kPlaying, stays playing; only debug: Prepared video sample is not conformant repeats, no error.
  • failing (field-coded channels): decoder created → video decoder fallback after initial decode error → no viable fallback → PipelineStatus code=3 / media_codec_video_decoder.cc:824 → playerState = errored.

So the failure is an initial decode error raised by the Kirin OMX decoder for this particular bitstream, while the same SoC decodes the same URL fine in the Huawei browser. Point 2 (field-coded H.264: frame_mbs_only=0, PAFF, pic_order_cnt_type=0, bottom_field_pic_order_in_frame_present=1 vs pic_order_cnt_type=2 on the working channels) is the only correlation I can find.

gdwengf avatar Oct 25 '26 08:10 gdwengf

Decisive test: same device, same browser, only the SPS differs

I cut 10 s of a failing channel into two fMP4 files that differ only in the video bitstream, then played both in the same Lemur (Chromium) browser on the same Kirin phone:

File Video bitstream Result
A original, remuxed (pic_order_cnt_type=0, field-coded) black screen
B re-encoded (pic_order_cnt_type=2, progressive, x264 -bf 0) plays fine

Same container, same audio (AAC), same page, same network. So the trigger is a property of the coded video — not the device's decoding capability, not the transport.

One more data point from the media-internals export: on some retries the failure surfaces one level deeper than the initial decode error:

MediaCodecResult   code=5 "Unexpected error occurred."      media/base/android/media_codec_bridge_impl.cc:701
QueueStatus        code=1                                    media/gpu/android/codec_wrapper.cc:272
DecoderStatus      code=1 "QueueInputBuffer failed"          media/gpu/android/media_codec_video_decoder.cc:970
PipelineStatus     code=3                                    media/renderers/video_renderer_impl.cc:592

QueueInputBuffer failed means the OMX component (OMX.hisi.video.decoder.avc) rejects the buffers Chromium queues for this stream, while the same SoC decodes the same stream fine in the Huawei browser.

Summary of what is established:

  1. Kirin + Chromium: OMX.hisi.video.decoder.avc is selected, then fails (initial decode error / QueueInputBuffer failed).
  2. Kirin + Huawei browser: same stream, same SoC — fine.
  3. Kirin + Chromium + re-encoded poc_type=2 stream: fine.
  4. Working channels in the same playlist are pic_order_cnt_type=2; every failing channel I sampled is pic_order_cnt_type=0 + bottom_field_pic_order_in_frame_present=1 + field-coded.

Is this something the player could work around (e.g. a different codec/profile string, byte-buffer vs surface output), or is it strictly a Chromium↔Kirin-vendor-decoder issue? Any pointer would be appreciated — I can supply the two sample files if you want to test locally.

gdwengf avatar Oct 25 '26 08:10 gdwengf