我在尝试使DeepAR的口罩出现在我的Agora视频通话中时遇到问题。我遵循了这个Github repo,但是当我设置它们对videoEncoderCOnfiguration和startFrameOutput的设置方式时,它对我来说很崩溃:
func setupVideo() {
agoraKit.setExternalVideoSource(true, useTexture: true, pushMode: true)
agoraKit.enableVideo()
agoraKit.disableAudio()
agoraKit.setVideoEncoderConfiguration(AgoraVideoEncoderConfiguration(size: AgoraVideoDimension640x360,
frameRate: .fps15,
bitrate: AgoraVideoBitrateStandard,
orientationMode: .adaptative))
}
func joinChannel() {
agoraKit.joinChannel(byToken: nil, channelId: "demoChannel1", info: nil, uid: 0) { [unowned self] (channel, uid, elapsed) -> Void in
// Did join channel "demoChannel1"
UIApplication.shared.isIdleTimerDisabled = true
self.localVideoView.startFrameOutput(withXmin: 0, xmax: 1, ymin: 0, ymax: 1, scale: 1)
self.localVideoView.isHidden = false
}
}
在self.arView.startFrameOutput(withXmin: 0, xmax: 1, ymin: 0, ymax: 1, scale: 1)
行之后,应用程序崩溃并显示此消息
*由于未捕获的异常'NSInvalidArgumentException'而终止应用程序,原因:'* -[__ NSArrayM insertObject:atIndex:]:对象不能为空'
当我根据如下所示的常规Agora呼叫回购设置呼叫时,该应用程序本身运行正常,但是即使我在可以正常工作的控制台中打印遮罩,我也无法在视频中看到遮罩。
func setupVideo() {
rtcEngine.enableVideo()
let canvas = AgoraRtcVideoCanvas()
canvas.uid = 0
canvas.view = localVideoView
canvas.renderMode = .hidden
rtcEngine.setupLocalVideo(canvas)
}
func joinChannel(channelId: String, token: String, uid: UInt) {
rtcEngine.joinChannel(byToken: token, channelId: channelId, info: nil, uid: uid) { (sid, uid, elapsed) in
self.callAnswered = true
self.showButtonsIfCallIsAnswered()
self.localVideoView.isHidden = false
}
UIApplication.shared.isIdleTimerDisabled = true
}
问题是即使控制台正在打印出该值,我也看不到掩码。当我像在DeepAR和Agora的仓库中那样设置外部视频源时,该应用程序在加入后立即崩溃。
我真的很感谢有人帮助我进行调试,以便所有操作都能顺利进行:)