client-sdk-react-native icon indicating copy to clipboard operation
client-sdk-react-native copied to clipboard

Streaming quality is not as good as `meet.livekit.io`

Open b0iq opened this issue 1 year ago • 10 comments

Describe the bug

The streaming quality is weird I tried several methods but still receiving quality is not same meet.livekit.io

To Reproduce

Steps to reproduce the behavior:

Room configs:

const room = new Room({
  adaptiveStream: {
    pixelDensity: 'screen',
  },
  publishDefaults: {
    videoSimulcastLayers: [VideoPresets.h720, VideoPresets.h1080],
    simulcast: false,
  },
  // optimize publishing bandwidth and CPU for published tracks
  dynacast: false,
  videoCaptureDefaults: {
    facingMode: 'user',
    resolution: VideoPresets.h720, // Cannot set it more than that!! 1080 and above will not work
  },
});

// -------- SETTING THE QUALITY 
trackStreamStateChanged(
  publication: RemoteTrackPublication,
  streamState: Track.StreamState,
  participant: RemoteParticipant
) {
  publication.setVideoQuality(2);
},

// -------- RENDERING REMOTE VIDEO
const RemoteVideo = () => {
  const remote = useLiveStore((state) => state.remoteVideo);
  if (!remote || remote.isMuted) return <ZLoading backgroundColor="red" zIndex={1} />;
  return (
    <VideoView
      objectFit="contain"
      videoTrack={remote}
      mirror={false}
      style={{ flex: 1, backgroundColor: 'red' }}
    />
  );
};

room is connected to cloud server...

Expected behavior

There problem is I cannot check the video quality only the connection quality and it is excellent but it should be better than meet.livekit.io because it is native

Screenshots

web viewer web publisher
IMG_6326 IMG_0863
app viewer app publisher
IMG_6327 IMG_0864

. . . . .

Most of the time the quality is worst, However, this is as highest as I can get

. . . . .

Device Info:

Viewer: iPhone 11 [16.1.2] Host: iPhone 14 [16.4.1]

Dependencies Info (please reference your package-lock.json or yarn.lock file):

  • @livekit/react-native: ^0.3.0
  • livekit-client: ^1.7.1
  • react-native-webrtc: ^111.0.0
  • Server region is in germany and am located it Dubai

b0iq avatar Apr 11 '23 20:04 b0iq

Discussed with reporter in Slack. The problem is both local and remote video appear lower resolution the RN app. b0iq will test with example app and report back.

davidzhao avatar Apr 12 '23 23:04 davidzhao

Hi again. I tried to reproduce with the example but not matter what I try it always failed to build. using old RN version cannot build on my machine. However, I create new vanilla RN project and try to do a minimal setup: https://github.com/b0iq/LKExample

The final result was not what I hoped for. it was same or worst.

Viewer (Web) Publisher (Web)
IMG_6333 IMG_0871
Viewer (App) Publisher (App)
IMG_6332 IMG_0870

b0iq avatar Apr 13 '23 13:04 b0iq

This is affecting us too. The video quality for web+mobile call, the mobile camera generated video is quite pixelated, grainy and lags quite a bit on latency in android.

pankajmyt avatar Apr 20 '23 09:04 pankajmyt

using 4/3 preset gives better quality, but improvements can be done.

pankajmyt avatar Apr 20 '23 11:04 pankajmyt

@pankajmyt does this repro with the example app?

What settings are you using with the Room object?

davidliu avatar Apr 21 '23 01:04 davidliu

const [room] = useState(() =>
      new Room({
        adaptiveStream: { pixelDensity: 'screen' },
        // publishDefaults: { simulcast: false },
        audioCaptureDefaults: {
          autoGainControl: true,
          echoCancellation: true,
          noiseSuppression: true,
        },
        videoCaptureDefaults: {
          facingMode: 'user',
          resolution: VideoPresets43.h540.resolution
        },
        publishDefaults: { 
          simulcast: false,
          videoSimulcastLayers: [VideoPresets43.h540, VideoPresets43.h720]
        },
        reconnectPolicy: {
          nextRetryDelayInMs: (context): number | null => {
            if (context.retryCount > 10) {
              return null
            }

            console.log(`retrying connection: retries: ${context.retryCount} sec: ${context.elapsedMs/1000} `)
            return 3000 //retry every 3 seconds
          }
        },
        disconnectOnPageLeave: true,
      }
  ));

pankajmyt avatar Apr 21 '23 04:04 pankajmyt

If you are sending simulcast: false, videoSimulcastLayers would have no effect there. Simulcast will not be used.

davidzhao avatar Apr 21 '23 06:04 davidzhao

:) yes, I have kept it there to remind myself to enable it later.

In readme it says simulcast is not supported, however in react-native-webrtc readme it says simulcast is supported. https://github.com/react-native-webrtc/react-native-webrtc/blob/master/README.md

Simulcast - As of version 111.0.0 Simulcast is now easily possible due to the use of software encode/decode factories by default.

pankajmyt avatar Apr 21 '23 06:04 pankajmyt

Simulcast is supported as of v1.0

davidzhao avatar Apr 21 '23 06:04 davidzhao

also you're setting resolution: VideoPresets43.h540.resolution as capture defaults, this will obviously limit the quality of the acquired camera track.

lukasIO avatar Apr 21 '23 10:04 lukasIO