Documentation
ExpressVideoSDK Video Call
Documentation
Demo APP
SDK Center
API Center
FAQ
Code Market
Console
Sign Up
Log In
中文站 English
  • Documentation
  • Video Call
  • Upgrade using advanced features
  • Advanced features
  • Configure the video
  • Configure video codec

Configure video codec

Last updated:2024-08-14 17:33

Introduction

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.

Prerequisites

Before you implement the video codec feature, make sure you complete the following steps:

  • A project has been created in ZEGOCLOUD Console and applied for a valid AppID and AppSign. For details, please refer to Console - How to view project information .
  • ZEGO Express SDK has been integrated into the project to implement basic real-time audio and video functions. For details, please refer to Integrate the SDK and Implement a basic video call.

Create video streams

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"));

Publishing a stream with the appropriate video codec

To start publishing streams and set the video codec, do the following:

  1. Call the startPublishingStream method to publish the local streams to the remote side (ZEGO server).
  2. Set the videoCodec property with VP8 or H264 (default value) to configure the video codec type.
  • To use "VP8" in your browser, please make sure that your current browser supports this encoding format.
  • If you want to publish a stream to a CDN (including CDN recording), do not set the video attribute to "VP8", as it will cause an abnormal recording file.
// [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'});
Page Directory
  • Free trial
  • 提交工单
    咨询集成、功能及报价等问题
    电话咨询
    400 1006 604
    Get Consulting
    Scan Wechat QR code