Video Encoding Format Selection
Overview
ZEGO Express Web SDK uses WebRTC technology to implement real-time audio and video functionality, with video encoding supporting both H.264 and VP8 formats. This article introduces the advantages and disadvantages of both encoding formats, and helps developers better understand how to choose the appropriate encoding format based on their business scenarios.
Compatibility Notes
Before starting to use audio and video services, developers can use the compatibility detection interface checkSystemRequirements provided by ZEGO Express Web SDK to detect the browser environment and devices, and prompt for related risks.
Encoding Format Comparison
The comparison of the two encoding formats is as follows:
| Encoding Format | Advantages | Disadvantages |
|---|---|---|
| H.264 | Mature ecosystem, supports direct relaying to CDN and direct interoperability with mini-programs. | Poorer support on mobile browsers, such as WeChat browser, WebView, etc. |
| VP8 |
| Poor ecosystem support, cannot directly relay to CDN or directly interoperate with mini-programs. |
Browser Compatibility
Desktop
| System | Browser | H.264 | VP8 |
|---|---|---|---|
| Windows |
| ✔️ | ✔️ |
| macOS |
| ✔️ | ✔️ |
| ChromeOS | Chrome | ✔️ | ✔️ |
-
Chrome
- On all Windows devices using AMD chips and some using Intel chips, when Chrome uses H.264 encoding, the sending bitrate may not reach the set value. Developers are recommended to use VP8 encoding or try disabling hardware acceleration.
- Chrome 84 on macOS has a defect. When using H.264 format for encoding, WebRTC may experience sudden frame rate drops, causing image stuttering. For details, please refer to the official Google explanation Issue 1088650 and Issue 12704. Developers are recommended to use VP8 format on Chrome 84 or above on macOS.
-
Safari
Safari 12.1 or below only supports H.264 codec.
-
Firefox
On Mac devices using Apple M1 chips, Firefox does not support H.264 codec. For details, see Firefox official explanation.
Mobile
Android
Android supports self-developed WebView or third-party WebView. Different devices and applications implement WebView differently, so ZEGO Express Web SDK's support for different application versions and device hardware also varies. Developers are recommended to perform compatibility detection before use.
| Browser | Function | H.264 | VP8 |
|---|---|---|---|
| WebView | Publish/Play stream | ✔️ | ✔️ |
| Chrome Browser | Publish/Play stream | ✔️ | ✔️ |
WebView includes WeChat built-in browser, Enterprise WeChat built-in browser, QQ built-in browser, DingTalk, Toutiao, etc. In these WebViews and Chrome browsers, the usage restrictions regarding browser versions, chip types, and encoding formats are as follows:
| Restriction Name | Restriction Description |
|---|---|
| Encoding Format | Using H.264 encoding to send video streams may result in a lower bitrate for the sent video stream, unable to reach the expected bitrate. |
| Chip | Cannot use H.264 encoding to send video streams on devices equipped with MediaTek chips. |
| Browser Version and Chip |
|
iOS
iOS only supports system WebView, so ZEGO Express Web SDK's support for WebView is only related to the iOS system version.
| Browser | Function | H.264 | VP8 |
|---|---|---|---|
| WebView (WeChat built-in browser, etc.) | Publish stream | ✔️ (iOS 14.3 or above) | |
| Play stream | ✔️ (iOS 12.1.4 or above) | ✔️ (iOS 12.2 or above) | |
| Safari Browser | Publish/Play stream | ✔️ (iOS 11 or above) | ✔️ (iOS 12.2 or above) |
When using H.264 encoding format to publish streams on iOS, 1080p or higher resolution video cannot be relayed to CDN.
Recommended Solutions
Based on the above compatibility notes and ZEGO market user data statistics, devices that do not support VP8 account for a relatively small proportion. VP8 is slightly better than H.264 in terms of browser compatibility. Therefore:
- When the business scenario is primarily Web platform, developers are recommended to use VP8 encoding format.
- If the developer's business scenario involves multiple platforms such as Web, iOS, Android, Windows, macOS, etc., and good multi-platform compatibility is desired, developers are recommended to use H.264 encoding format.
Specific scenario recommendations are as follows:
| Host Side | Audience Side | Recommended Encoding Format | Advantages | Disadvantages | Application Scenarios |
|---|---|---|---|---|---|
| WebRTC | WebRTC | VP8 | Best compatibility and quality. | - | Bank/Securities Account Opening |
| CDN | H.264 | No transcoding required. | Some device models do not support H.264 encoding when the host publishes streams. | Showroom Live Streaming | |
| VP8 | Better publisher compatibility. | Requires manual transcoding. | |||
| Mini Program | H.264 | No transcoding required. | Some device models do not support H.264 encoding when the host publishes streams. | Bank/Securities Account Opening |
- When playing streams on Web, there is no need to specify the encoding format. The SDK will automatically select the format based on the publishing encoding.
- When Web selects VP8 encoding format and interoperates with Native UDP, Native needs to specify VP8 encoding format (supported by default build).
Regardless of choosing H.264 or VP8, compatibility detection must first be performed on the browser being used. Developers can check browser compatibility through the checkSystemRequirements interface, which is also a prerequisite for the SDK to automatically select encoding.
Transcoding refers to converting video signals from one format to another. ZEGO services support conversion of audio and video encoding formats, resolution, bitrate, etc. Developers can refer to the Stream Mixing Transcoding Example Demo. For questions, please contact ZEGOCLOUD Technical Support.
