Vedha
Vedha

Reputation: 13

Agora CDN streaming from Web Sdk multiple users

To push an agora channel with multiple users to a CDN, do I need to call the following methods for every user? Or does setting transcoding and starting live streaming for one host automatically start streaming for everyone in the channel. Also, are there any default transcoding layouts like there are for recording?

client.setLiveTranscoding(LiveTranscoding);
client.startLiveStreaming("your RTMP URL", true)

Upvotes: 1

Views: 409

Answers (1)

Hermes
Hermes

Reputation: 2898

To push all users in a channel you only need to call setLiveTranscoding and startLiveStreaming from a single user. Within the Live Transcoding Config object you would set the number of users with the userCount property and customize the various settings for each user with the transcodingUsers object.

// CDN transcoding settings.
var liveTranscodingConfig = {
  // Width of the video (px). The default value is 640.
  width: 640,
  // Height of the video (px). The default value is 360.
  height: 360,
  // Bitrate of the video (Kbps). The default value is 400.
  videoBitrate: 400,
  // Frame rate of the video (fps). The default value is 15. Agora adjusts all values over 30 to 30.
  videoFramerate: 15,
  audioSampleRate: AgoraRTC.AUDIO_SAMPLE_RATE_48000,
  audioBitrate: 48,
  audioChannels: 1,
  videoGop: 30,
  // Video codec profile. Choose to set as Baseline (66), Main (77), or High (100). If you set this parameter to other values, Agora adjusts it to the default value of 100.
  videoCodecProfile: AgoraRTC.VIDEO_CODEC_PROFILE_HIGH,
  userCount: 1,
  userConfigExtraInfo: {},
  backgroundColor: 0x000000,
  // Adds a PNG watermark image to the video. You can add more than one watermark image at the same time.
  images: [{
          url: "http://www.com/watermark.png",
          x: 0,
          y: 0,
          width: 160,
          height: 160,
      }],
  // Sets the output layout for each user.
  transcodingUsers: [{
          x: 0,
          y: 0,
          width: 640,
          height: 360,
          zOrder: 0,
          alpha: 1.0,
          // The uid must be identical to the uid used in Client.join.
          uid: 1232,
        }],
};

client.setLiveTranscoding(liveTranscodingConfig);
client.startLiveStreaming("your RTMP URL", true)

Upvotes: 1

Related Questions