提交工单
咨询集成、功能及报价等问题
ZEGOCLOUD’s SDK supports choosing the different video codec types accordingly to realize the coding alignment across multiple ends.
You can select H.264
or VP8
based on the actual situation. For better browser compatibility, use VP8
. For better interoperability, use H.264
.
Before you implement the video codec feature, make sure you complete the following steps:
To create the video streams, call the createZegoStream method and set the camera
property for creating the media (camera and microphone) source stream.
// After calling the createZegoStream method, you need to wait for the ZEGO server to return the local stream object before any further operation.
const localStream = await this.zg.createZegoStream();
// Play preview of the stream
localStream.playVideo(document.querySelector("#local-video"));
To start publishing streams and set the video codec, do the following:
startPublishingStream
method to publish the local streams to the remote side (ZEGO server).videoCodec
property with VP8
or H264
(default value) to configure the video codec type. // [publishStreamId] must be global unique.
// videoCodec: The video codec for stream publishing, pass the [VP8] (string) or 'H264' (string). Default valus is [H264].
const result = zg.startPublishingStream(publishStreamId, localStream, {videoCodec: 'VP8'});