First off, I’m not entirely sure if this is a mediasoup issue or a webRTC issue, but any help would be greatly appreciated.
When attempting to do a long-term session of screen sharing, I find that the audio and video go out of sync intermittently. It does self-correct sometimes, but more often than not, there is clear de-sync. The video is almost always lagging behind audio. So far, I have tried VP8 and H264 for the video codec and while H264 is more resilient to de-sync, it still occurs at some point.
Initially, I thought this might be a CPU bottleneck, since video encoding/decoding takes time, but the de-sync occurs even on a modern CPU (Ryzen 9 3900X) under minimal load.
What could be causing this? Are there any parameters/codecs/settings that I can use to minimize the de-sync?
This happens to consumers on both, Chrome and Firefox.
The producer is on Chrome, since only Chrome supports sharing screen with audio. I believe both browsers are at their latest stable versions.
Try setting a lower resolution. Or better yet, turn on ‘dtx’ in the encodings options of the producer, and set a lower frame rate say 5 fps. I think the decoding of 1080p video in real time vs audio which is much easier is the issue.
Chrome can just sync a received audio and a received video from the same source, so if the screen sharer is sending also mic, there is a good chance for audio and video from sharing to not be rendered in sync.