# audio-video desync

**URL:** <https://mediasoup.discourse.group/t/audio-video-desync/1391>\
**Category:** mediasoup libraries\
**Created:** [July 4, 2020, 1:21pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391 "2020-07-04T13:21:40Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![gurupras](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/gurupras/32/738_2.png) [@gurupras](https://mediasoup.discourse.group/u/gurupras)\
**Post date:** [July 4, 2020, 1:21pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/1 "2020-07-04T13:21:40Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![TheSalarKhan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/thesalarkhan/32/630_2.png) [@TheSalarKhan](https://mediasoup.discourse.group/u/TheSalarKhan)\
**Post date:** [July 4, 2020, 6:35pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/2 "2020-07-04T18:35:07Z")

</div>

What browser are you using?

---

<div class="post-metadata">

**Author:** ![gurupras](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/gurupras/32/738_2.png) [@gurupras](https://mediasoup.discourse.group/u/gurupras)\
**Post date:** [July 4, 2020, 6:55pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/3 "2020-07-04T18:55:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![TheSalarKhan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/thesalarkhan/32/630_2.png) [@TheSalarKhan](https://mediasoup.discourse.group/u/TheSalarKhan)\
**Post date:** [July 4, 2020, 6:57pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/4 "2020-07-04T18:57:44Z")

</div>

I have not measured a delay between video and audio when screen sharing. Do you get the same result when sharing camera?

---

<div class="post-metadata">

**Author:** ![gurupras](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/gurupras/32/738_2.png) [@gurupras](https://mediasoup.discourse.group/u/gurupras)\
**Post date:** [July 4, 2020, 7:02pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/5 "2020-07-04T19:02:31Z")

</div>

No, at this point, we’ve done hundreds of hours of webcam and have not observed any noticeable de-sync.

That said, I will also point out that my webcam video resolution was 320x240, whereas the screen resolution was at 1920x1080.

---

<div class="post-metadata">

**Author:** ![TheSalarKhan](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/thesalarkhan/32/630_2.png) [@TheSalarKhan](https://mediasoup.discourse.group/u/TheSalarKhan)\
**Post date:** [July 4, 2020, 7:06pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/6 "2020-07-04T19:06:01Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [July 8, 2020, 9:49pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/7 "2020-07-08T21:49:03Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![gurupras](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/gurupras/32/738_2.png) [@gurupras](https://mediasoup.discourse.group/u/gurupras)\
**Post date:** [July 8, 2020, 10:53pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/8 "2020-07-08T22:53:53Z")

</div>

I’m not sure what ‘same source’ means here, but I _am_ getting them both from one `navigator.mediadevices.getDisplayMedia` call:

```auto
navigator.mediaDevices.getDisplayMedia({
  audio: {
    noiseSuppression: false,
    autoGainControl: false,
    echoCancellation: false,
    latency: 0,
    sampleRate: 48000
  },
  video: {
    width: 1920,
    height: 1080,
    frameRate: 30,
    latency: 0
  }
})

```

Is this not considered as the same source?

---

<div class="post-metadata">

**Author:** ![ibc](https://yyz2.discourse-cdn.com/free1/user_avatar/mediasoup.discourse.group/ibc/32/1540_2.png) [@ibc](https://mediasoup.discourse.group/u/ibc)\
**Post date:** [July 8, 2020, 11:53pm UTC](https://mediasoup.discourse.group/t/audio-video-desync/1391/9 "2020-07-08T23:53:33Z")

</div>

Try with just mic and webcam. There is no desync, right? mediasoup is not responsible if Chrome does not send sharing audio and video in sync.
