CDN live streaming refers to the process of publishing streams to the CDN (Content Delivery Network), where users can view a live broadcast with a web browser.
You can use transcoding to combine the streams of all hosts in the channel into one stream, or set the audio/video profiles and picture-in-picture layout for the stream to be published to the CDN.
Ensure that you enable the RTMP Converter service before using this function.
Now, you can use the function and see the usage statistics.
checkSystemRequirements()
createClient()
init(appId, onSuccess, onFailure)
join(channelKey, channel, uid, onSuccess, onFailure)
createStream(spec)
var LiveTranscoding = {
width: 640, // Width of the video. Positive integer, the default value is 640. The value range is [16, 10000].
height: 360, // Height of the video. Positive integer, the default value is 360. The value range is [16, 10000].
videoBitrate: 400, // Bitrate of the CDN live output video stream. Positive integer. The default value is 400 Kbps.
videoFramerate: 15, // Frame rate (fps) of the CDN live output video stream. The default value is 15. Agora adjusts all values over 30 to 30.
lowLatency: false,
audioSampleRate: 48000,
audioBitrate: 48,
audioChannels: 1,
videoGop: 30,
videoCodecProfile: 100, // Video codec profile type: 66, 77, 100. If you set this parameter to other values, Agora adjusts it to the default value 100.
userCount: 0,
userConfigExtraInfo: {},
backgroundColor: 0x000000,
transcodingUsers: [],
};
Set
videoBitrate
according to the Video Bitrate Table.If you set a bitrate beyond the proper range, the SDK automatically adapts it to a value within the range.
client.setLiveTranscoding(coding);
client.startLiveStreaming(url, true) //If enableTranscoding is set to true, setLiveTranscoding must be called before _startLiveStreaming.
client.stopLiveStreaming(url);
leave(onSuccess, onFailure)