首页 > 解决方案 > React-native-agora 远程视频质量很差,只能卡死

问题描述

我正在开发一个 react native 视频通话应用程序,我使用 react-native-agora,一切正常,除了远程视频质量非常糟糕,我什么也看不到,它只是冻结。我使用 react native agora 版本:3.2.2

我的 rtcEngine 初始化函数:

/**
 * @name init
 * @description Function to initialize the Rtc Engine, attach event listeners and actions
 */
const init = async () => {
    const {token, appId} = await getToken();
    setAppId(appId);
    setToken(token);
    engine = await RtcEngine.create(appId);
    await engine.enableVideo();
    await engine.enableAudio();
    await engine?.joinChannel(token, `${session.id}`, null, 0);

    engine.addListener('Warning', (warn) => {
        console.log('Warning', warn);
    });

    engine.addListener('Error', async (err) => {
        if(err === 17){
            if(!engine){
                engine = await RtcEngine.create(appId);
            }
            await engine?.leaveChannel();
            setPeerIds(peerIds => []);
            await engine?.joinChannel(token, `${session.id}`, null, 0);
        }
        console.log('Error', err);
    });

    engine.addListener('UserJoined', async (uid, elapsed) => {
        console.log('UserJoined', uid, elapsed);
        // Get current peer IDs
        // If new user
        if (peerIds.indexOf(uid) === -1) {
            setPeerIds(peerIds => [...peerIds, uid]);
        }
    });

    engine.addListener('UserOffline', (uid, reason) => {
        console.log('UserOffline', uid, reason);
        setPeerIds(peerIds => [...peerIds.filter((id) => id !== uid)]);
    });

    // If Local user joins RTC channel
    engine.addListener('JoinChannelSuccess', (channel, uid, elapsed) => {
        console.log('JoinChannelSuccess', channel, uid, elapsed);
        // Set state variable to true
        setJoinSucceed(true);
    });
}

提前致谢。

标签: react-nativeagora.io

解决方案


我终于解决了我的问题,对于那些有同样问题的人,我在这里给出我的解决方案:

我只是制作了这个 videoEncoderConfiguration :

await engine.setVideoEncoderConfiguration(new VideoEncoderConfiguration({
        dimensions: new VideoDimensions(320, 240),
        bitrate: 140,
        frameRate: VideoFrameRate.Fps30,
        degradationPrefer: 0
    }))

推荐阅读