Javascript agora.io web sdk-获取外部播放器的流链接

Javascript agora.io web sdk-获取外部播放器的流链接,javascript,agora.io,Javascript,Agora.io,我使用Javascript和Agora.IO为livestreaming应用程序编写了一个客户端,我希望获得一个流URL,如RTMP或HLS格式,用户可以将其粘贴到外部播放器(如VLC)中以查看livestreams stream对象有一个play()方法,我可以使用它在web浏览器中播放流,但是是否有可能生成/获取流的链接?感谢您的帮助/提示如何完成此任务!下面是到目前为止我的代码,通过它我连接到一个带有房间号和用户id的livestream var client = AgoraRTC.cre

我使用Javascript和Agora.IO为livestreaming应用程序编写了一个客户端,我希望获得一个流URL,如RTMP或HLS格式,用户可以将其粘贴到外部播放器(如VLC)中以查看livestreams

stream对象有一个play()方法,我可以使用它在web浏览器中播放流,但是是否有可能生成/获取流的链接?感谢您的帮助/提示如何完成此任务!下面是到目前为止我的代码,通过它我连接到一个带有房间号和用户id的livestream

var client = AgoraRTC.createClient({
  mode: "live",
  codec: "h264"
});

client.init('my_app_ID', function() {
  console.log("AgoraRTC client initialized");

}, function(err) {
  console.log("AgoraRTC client init failed", err);
});
client.join(null, room_number + "", user_id, function(user_id) {
  console.log(user_id);
});

client.on("stream-added", function(t) {
  var stream = t.stream;

  client.subscribe(stream, {
    video: !0,
    audio: !0
  });

  client.on("stream-subscribed", function(e) {
    var t = e.stream;
    t.play('agora_remote'); // plays the stream into a DIV element
  });
});

io的Web SDK不提供任何通过RTMP访问流的方法,因为Agora Web SDK基于Web RTC,这是一种不同的协议

Agora.io的Web SDK支持使用
setLiveTranscoding
StartiveStreaming
stopLiveStreaming
方法将Agora流推送到RTMP url(由Facebook Live、YouTube Live、Vimeo Live等服务提供)

// CDN transcoding settings.
var LiveTranscoding = {
            // 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,
            // 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(LiveTranscoding);

// Adds a URL to which the host pushes a stream. Set the transcodingEnabled parameter as true to enable the transcoding service. Once transcoding is enabled, you need to set the live transcoding configurations by calling the setLiveTranscoding method. We do not recommend transcoding in the case of a single host.
client.startLiveStreaming("your RTMP URL", true)


// Removes a URL to which the host pushes a stream.
client.stopLiveStreaming("your RTMP URL")

完整指南:

感谢您提供详细的指南和参考代码。我遵循上述代码,但无法设置实时转码

“03:16:14:369 Agora SDK[调试]:setLiveTranscoding:{“宽度”:640,“高度”:360,“视频比特率”:400,“视频帧率”:15,“音频采样器”:48000,“音频比特率”:48,“音频频道”:1,“视频GOP”:30,“视频编码档案”:100,“用户计数”:1,“用户配置外部信息”:{},“背景色”:0,“图像”:[{“url”:“x”:0,“y”:0,“宽度”:160,“高度”:160}”代码转换器“:[{“x”:0,“y”:0,“宽度”:640,“高度”:360,“zOrder”:0,“alpha”:1,“uid”:3882108012}]}”

我从“rtc.client.setLiveTranscoding(LiveTranscoding)”中得到上述响应,agora控制台的“RTMP Converter”区域中没有显示任何内容