修改视频采集、视频编码的方法如下:
// 视频采集
RtcEngine.setCameraCapturerConfiguration(
// default 640*480, 15fps
CameraCapturerConfiguration(CameraCapturerConfiguration.CaptureFormat().apply {
this.width = 960
this.height = 540
this.fps = 15
}))
// 设置视频编码属性
RtcEngine.setVideoEncoderConfiguration(VideoEncoderConfiguration().apply {
this.dimensions = VideoEncoderConfiguration.VD_960x540
})
测试结果如下(xiaomi是测试机器,huawei是另一端的观测机器):
#1. 不额外设置,都是默认值
#xiaomi (sender)
#onLocalVideoStats, stats.captureFrame 360*640, stats.encodedFrame 360*640, stats.regulatedCaptureFrame 360*640
# huawei (receiver)
#onRemoteVideoStats, stats 360*640
#2. 只设置 setVideoEncoderConfiguration(VD_960x540)
#xiaomi (sender)
#onLocalVideoStats, stats.captureFrame 720*960, stats.encodedFrame 540*960, stats.regulatedCaptureFrame 540*960
# huawei (receiver)
#onRemoteVideoStats, stats 540*960
#3. 只设置 setCameraCapturerConfiguration(width=960, height=540)
#xiaomi (sender)
#onLocalVideoStats, stats.captureFrame 720*960, stats.encodedFrame 360*640, stats.regulatedCaptureFrame 540*960
# huawei (receiver)
#onRemoteVideoStats, stats 360*640
#4. 同时设置 setCameraCapturerConfiguration(width=960, height=540), setVideoEncoderConfiguration(VD_960x540)
#xiaomi (sender)
#onLocalVideoStats, stats.captureFrame 720*960, stats.encodedFrame 540*960, stats.regulatedCaptureFrame 540*960
# huawei (receiver)
#onRemoteVideoStats, stats 540*960
从上面可以看出,默认采集、编码的分辨率都是360*640,和文档不一致。
960 × 540 是默认视频编码分辨率,需要确认是否有调用 setVideoEncoderConfiguration 设置分辨率,如果调用接口设置了分辨率那么还是会以接口参数设置为准哈
https://docs.agora.io/cn/video-call-4.x/API%20Reference/java_ng/API/class_videoencoderconfiguration.html