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.

The following figure shows a typical CDN-pushing scenario.


Ensure that you enable the RTMP Converter service before using this function.

  1. Log in Console, and click img in the left navigation menu to go to the Products & Usage page.
  2. Select a project from the drop-down list in the upper-left corner, and click Duration under RTMP Converter.
  3. Click Enable RTMP Converter.
  4. Click Apply to enable the RTMP Converter service and get 500 max concurrent channels.
The number of concurrent channels, N, means that users can push streams to the CDN with transcoding in N channels of media streams.

Now, you can use the function and see the usage statistics.


Agora's CDN publishing solution is based on the following API methods to publish streams to the CDN, inject external audio streams, transcode, and set the output layout.

In which:

  • The host calls the setLiveTranscoding method to set the transcoding parameters, for example, the canvas settings, after joining a channel. The host still needs to set a 16 × 16 view when only publishing an audio stream to CDN.
  • The host adds or removes a URL with the addPublishStreamUrl and removePublishStreamUrl methods after joining the channel.

Sample Code

// CDN transcoding settings.
AgoraLiveTranscodingUser *user = [[AgoraLiveTranscodingUser alloc] init];
user.uid = 12345;
user.rect = CGRectMake(0, 0, 16, 16);
user.audioChannel = 0;

AgoraRtcEngineKit *rtcEngine = [AgoraRtcEngineKit sharedEngineWithAppId:@"" delegate:nil];
AgoraLiveTranscoding *transcoding = [[AgoraLiveTranscoding alloc] init];
transcoding.audioSampleRate = AgoraAudioSampleRateType44100;
transcoding.audioChannels = 2;
transcoding.size = CGSizeMake(16, 16);
transcoding.videoFramerate = 15;
transcoding.videoCodecProfile = AgoraVideoCodecProfileTypeHigh;
transcoding.transcodingUsers = @[user];

[rtcEngine setLiveTranscoding:transcoding];
// Adds a URL to which the host pushes a stream.
// Set the transcodingEnabled parameter as YES to enable the transcoding service. Once transcoding is enabled, you nee to set the live transcoding configurations by calling the setLiveTranscoding method. We do not recommend transcoding in the case of a single host.
[rtcEngine addPublishStreamUrl:streamUrl transcodingEnabled:YES];
// Removes a URL to which the host pushes a stream.
[rtcEngine removePublishStreamUrl:streamUrl];