How to get a video stream encoded in H.264 to play in a “WebView”?

青春壹個敷衍的年華 提交于 2021-01-27 19:06:04

问题


I have a remotely hosted webpage with an html5 video player that streams H.264-encoded video. I need to embed this page (not open externally in a browser) in my Android Activity. The latest Android System Webview (ver 63.0) doesn't support H.264 encoding nor does Crosswalk's Webview (matching my hardware architecture). What are my options?


回答1:


Updated answer

After some digging, it seems that the webview in Android does indeed have issues supporting h.264. This is because it is based on Chromium which does not include h.264 support by default (long history involving patents etc).

The most common recommendation at the moment appears to be to build your own Chromium web view, with the build options/flags to include h.264.

This is a know limitation with Chrome and there is an open bug listed here at the time of writing:

  • https://bugs.chromium.org/p/chromium/issues/detail?id=719023

The differences between Chrome and Chromium are well documented elsewhere, but one of the key points in this context is that Chromium is completely open source so avoids including proprietary components, and this is why the licensed H.264 codec is not included.

Original answer with corrections

[Unless something has just changed, the standard Android web view should support] Android devices and the Android chrome browser generally support h.264 video (so long as the profile and settings are within the set the device supports - testing with baseline profile initially is a safe way to start). However, the Android Webview, which is Chromium based, does not support h.264 at the time of writing.

The default set of supported video formats is available here: https://developer.android.com/guide/topics/media/media-formats.html#video-formats

There are known/reported WebRTC and h.264 issues in Android web views but the consensus is that this is webRTC related, AFAIK - see: https://groups.google.com/a/chromium.org/forum/#!topic/android-webview-dev/hVZdHK6MKfI




回答2:


There are two different issues making a H.264 video stream not working on Chrome for Android (that are often mixed up):

1) Chrome for Android has only a hardware implementation for H.264 and there is no software implementation. At this moment H.264 works only with devices with a processor of Qualcomm (Kitkat and later) or Samsung Exynos (Lollipop and later).

2) There is bug in Chrome for Android related to H.264

Error message like these:

Unhandled Promise Rejection: OperationError (DOM Exception 34): 
Failed to set remote offer sdp: Session error code: ERROR_CONTENT. 
Session error description: Failed to set remote video description send parameters..

Chrome Android does not offer/answer H.264 Constrained Baseline Profile

This problem will probably be solved in Chrome Android M65. See this for more information.

Since you have the same error message (seeing this as comment under the other answer), your problem is related to this bug.



来源:https://stackoverflow.com/questions/48322413/how-to-get-a-video-stream-encoded-in-h-264-to-play-in-a-webview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!