electron 调用addInjectStreamUrl之后报错

this.startLive(keyPath[0],‘https://dianbo.secon.cn/3d559db268e64feabe72413c1fdcd422/c7590749f01f5d224090c71570c3541c-ld.mp4?auth_key=1599124631-2ddd525375c94c238ceda21603af6b04-0-8d6fa43e4325d3e61cffbfc3bf772558’)

startLive(channel,video_url) {
// Code that will run only after the
// entire view has been rendered
if(global.rtcEngine) {
// if rtc engine exists already, you must call release to free it first
global.rtcEngine.release()
}
const consoleContainer = document.querySelector(’#console’)
const localVideoContainer = document.querySelector(’#local’)

            let rtcEngine = new AgoraRtcEngine()
            rtcEngine.initialize(APPID)

            // listen to events
            rtcEngine.on('joinedChannel', (channel, uid, elapsed) => {
	            //called when join channel success
	            consoleContainer.innerHTML = `joined channel ${channel} with uid ${uid}, elapsed ${elapsed}ms`
	            //setup render area for local user
	            rtcEngine.setupLocalVideo(localVideoContainer)

	            //prepare rtmp streaming state listener
	            rtcEngine.on('rtmpStreamingStateChanged', (url, state, code) => {
		            consoleContainer.innerHTML = (`rtmpStreamingStateChanged ${url} ${state} ${code}`)
	            })

	            //start live RTMP streaming after join
	            rtcEngine.setLiveTranscoding({
		            /** width of canvas */
		            width: 1024,
		            /** height of canvas */
		            height: 720,
		            /** kbps value, for 1-1 mapping pls look at https://docs.agora.io/cn/Interactive%20Broadcast/API%20Reference/cpp/structagora_1_1rtc_1_1_video_encoder_configuration.html */
		            videoBitrate: 500,
		            /** fps, default 15 */
		            videoFrameRate: 15,
		            /** true for low latency, no video quality garanteed; false - high latency, video quality garanteed */
		            lowLatency: true,
		            /** Video GOP in frames, default 30 */
		            videoGop: 30,
		            videoCodecProfile: 77,
		            /**
		             * RGB hex value. Value only, do not include a #. For example, 0xC0C0C0.
		             * number color = (A & 0xff) << 24 | (R & 0xff) << 16 | (G & 0xff) << 8 | (B & 0xff)
		             */
		            backgroundColor: 0xc0c0c0,
		            /** The number of users in the live broadcast */
		            userCount: 1,
		            audioSampleRate: 32000,
		            audioChannels: 1,
		            audioBitrate: 48,
		            /** transcodingusers array */
		            transcodingUsers: [
			            {
				            uid: uid,
				            x: 0,
				            y: 0,
				            width: 320,
				            height: 240,
				            zOrder: 1,
				            alpha: 1,
				            audioChannel: 1
			            }
		            ],
		            watermark: {
			            url: "",
			            x: 0,
			            y:0,
			            width: 80,
			            height: 80
		            }
	            });
	            const InjectStreamConfig = {
		            width: 680,
		            height: 480,
		            videoGop: 30,
		            videoFramerate: 15,
		            videoBitrate: 400,
		            audioSampleRate: 44100,
		            audioChannels: 1,
	            };
	            rtcEngine.addInjectStreamUrl(
		            video_url,
                    InjectStreamConfig
	            );
            })
            rtcEngine.on('error', (err, msg) => {
	            consoleContainer.innerHTML = `error: code ${err} - ${msg}`
            })
            rtcEngine.on('userJoined', (uid) => {
	            //setup render area for joined user
	            //we don't demonstrate remote stream here, so we will mute remote video stream receiving
	            // rtcEngine.muteRemoteVideoStream(uid, true)
	            let remoteVideoContainer = document.querySelector('#remote')
                rtcEngine.setupRemoteVideo(uid,remoteVideoContainer,channel)
	            rtcEngine.subscribe(uid, remoteVideoContainer)
	            rtcEngine.setupViewContentMode(uid, 1);

            })

            // set channel profile, 0: video call, 1: live broadcasting
            rtcEngine.setChannelProfile(1)
            rtcEngine.setClientRole(1)

            // enable video, call disableVideo() is you don't need video at all
            rtcEngine.enableVideo()

            // set where log file should be put for problem diagnostic
            rtcEngine.setLogFile(sdkLogPath)

            this.$post('/user/agora/token',{
                channelName: channel,
                role: 1,
                deviceId: LIVE_UID
            }).then(res => {
            	if(res.response&&res.response.token){
	                // join channel to rock!
                    console.log('joinChannel')
	                rtcEngine.joinChannel(res.response.token, channel, null, LIVE_UID)
                }
            })


            global.rtcEngine = rtcEngine
        }

直播画面正常,但是输入媒体流后报错如下:

api agora::rtc::NodeRtcEngine::addInjectStreamUrl failed. this is an error
thrown by c++ addon layer. it often means sth is
going wrong with this function call and it refused
to do what is asked. kindly check your parameter types
to see if it matches properly.

现在问题解决了吗?检查看下是否有开通旁路推流权限:
https://docs.agora.io/cn/Interactive%20Broadcast/cdn_streaming_web?platform=Web#前提条件

加之前已经开通了,我现在换web sdk正常了

好的

还是得麻烦查下原因,web不支持同时加入多个channel, 满足不了我们业务,还得麻烦看下electron sdk为何会报错呢

麻烦给下具体的 sdk 日志

支持的啊,创建多个 client 即可

agoramainsdk.zip (19.6 KB)

那太棒了,谢谢!

日志里没看到 addInjectStreamUrl 调用成功的记录。从报错信息来看,应该是你调用该方法时填的参数类型有问题,导致调用失败,你再对照api文档检查看下哈
https://docs.agora.io/cn/Interactive%20Broadcast/API%20Reference/electron/classes/agorartcengine.html#addinjectstreamurl