# Audio Video not in sync - Individual Recording

**URL:** https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912
**Category:** How to implement?
**Tags:** v2
**Created:** [August 26, 2020, 1:43pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912 "2020-08-26T13:43:57Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [August 26, 2020, 1:43pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/1 "2020-08-26T13:43:57Z")

</div>

I am using **Individual recording**.in Openvidu PRO, Session total duration is approx 10 minutes. The first Stream which is for 3:25 minutes is fine and after that **Broadcaster Refreshed the page** and a new recording streams was generated.  
On the second STREAM which got generated after the Page Refreshed in not in Sync. We are facing AV syncing issue in this Stream

Can you please let me know the possible reason and fixes around that?

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 17, 2020, 4:04am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/2 "2020-09-17T04:04:06Z")

</div>

Faced AV lag issue again, but it’s a little bit strange.  
When i run the video in chrome the AV lag is significant but when i play the same video in Mozilla the lag is marginal.

**I also noticed for some Recording** - In the beginning everything sounds fine, but slowly the audio goes faster than the video.

P.S - There was no lag in AV during live session @ load of Media server was below 15%.  
@pabloFuente @cruizba any suggestion what can be the reason behind this.

---

<div class="post-metadata">

### Author: ![micael.gallego](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/micael.gallego/32/2_2.png) [@micael.gallego](https://openvidu.discourse.group/u/micael.gallego)
#### Post date: [September 18, 2020, 11:29pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/3 "2020-09-18T23:29:23Z")

</div>

Are you saying that if you play the recorded files in Chrome you see lag but if you play the recorded file in Firefox you don’t see lag?

Or are you saying that using Chrome for video call produces lag in recordings and using Firefox for video call don’t?

What type of recording are you using? INDIVIDUAL or COMPOSED?

Can you reproduce the issue? Can you share the files with us to analyse them?

Regards

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 19, 2020, 5:45am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/4 "2020-09-19T05:45:35Z")

</div>

@micael.gallego , Please find my inputs

- Broadcaster uses Chrome browser for live sessions.
- We are using INDIVIDUAL recording.
- Live session is based on 1-N topology.
- I’m saying that if i play the recorded files in Chrome i see significant lag but if i play the recorded file in Firefox, lag is also there but it’s marginal or negotiable.
- For some of the recording, everything sound fine in the beginning, but slowly the audio goes faster than the video (AV desync).
- All such sessions where we are facing AV lag was running smooth during Live sessions.

I have shared one recording file with you, you can check the same. For example if you

- Seek the video to 38 minutes and play for 2 mints and see the difference in both browser
- Seek the video to 1 hr 21 minutes and play for 1-2 mints and see the difference in both browser.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 23, 2020, 9:03am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/5 "2020-09-23T09:03:03Z")

</div>

@micael.gallego any update on this recording desync issue.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 28, 2020, 4:39am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/6 "2020-09-28T04:39:42Z")

</div>

Hello @micael.gallego , any clue why AV lag found while playing it in Chrome.

---

<div class="post-metadata">

### Author: ![j1elo](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/j1elo/32/1516_2.png) [@j1elo](https://openvidu.discourse.group/u/j1elo)
#### Post date: [September 28, 2020, 10:15am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/7 "2020-09-28T10:15:43Z")

</div>

Hi,

would you please be able to provide:

- A sample recording that shows this A/V out of sync issue (I’ve now received it already)
- A KMS log file that corresponds to the creation of one of these faulty recordings.

For the **KMS log file** , please first enable **advanced recorder logging**. To do that, follow these steps:

1. In all of your Media Nodes, update `/opt/kms/.env` file with these 2 lines:

```nohighlight
KMS_DEBUG_LEVEL=3,Kurento*:4,kms*:4,sdp*:4,webrtc*:4,*rtpendpoint:4,rtp*handler:4,rtpsynchronizer:4,agnosticbin:4,basemediamuxer:5,KurentoRecorderEndpointImpl:4,recorderendpoint:5,qtmux:5,curl*:5
GST_DEBUG=3,Kurento*:4,kms*:4,sdp*:4,webrtc*:4,*rtpendpoint:4,rtp*handler:4,rtpsynchronizer:4,agnosticbin:4,basemediamuxer:5,KurentoRecorderEndpointImpl:4,recorderendpoint:5,qtmux:5,curl*:5

```

1. Restart each of the Media Nodes: run `/opt/kms/media_node restart`.

2. Restart your main OpenVidu Server Pro Node: run `/opt/openvidu/openvidu restart`.

Having this, I’ll be able to inspect the details and have more information about the sync issue.

Thanks

---

<div class="post-metadata">

### Author: ![j1elo](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/j1elo/32/1516_2.png) [@j1elo](https://openvidu.discourse.group/u/j1elo)
#### Post date: [September 28, 2020, 11:20am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/8 "2020-09-28T11:20:25Z")

</div>

Also if you’re able to know (from application logs or any other means) what is the exact browser that was used as source for this recorder, it would also help. Browser name (Chrome, Firefox, Safari, etc) and version number.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 28, 2020, 11:26am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/9 "2020-09-28T11:26:27Z")

</div>

@j1elo

- A sample recording that shows this A/V out of sync issue (I’ve now received it already) - **Have shared 2 recording files with you. If not received please let me know.**

- A KMS log file that corresponds to the creation of one of these faulty recordings.  
**All media nodes are added on the fly (auto scale mode) hence KMS log won’t be available from there, Please let me know is there any other options available.**

- Browser name (Chrome, Firefox, Safari, etc) and version number.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 28, 2020, 12:15pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/10 "2020-09-28T12:15:05Z")

</div>

@j1elo, Source of Recording Browser was Chrome and Version 85 (Windows).

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 28, 2020, 4:33pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/11 "2020-09-28T16:33:20Z")

</div>

@j1elo, I get below error/warning messages from Chrome which has sync problem. It shows below message on **chrome://media-internals** Please see the attached screen shots for 3 different recordings which has AV syncing issue. Please see if this can help to understand the behaviour.

**Recording File -1**  
 ![AV-Sync-1](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/7a101f7c41dc62b87fcecd8377181a8990be67ca.png)

**Recording File 2**

 ![AV-Sync-3](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/b2550cc03f91831c52ce4e907e0383edd9c5e60f.png)

**Recording File 3**

 ![AV-SYnc-2](https://global.discourse-cdn.com/free1/uploads/openvidu/original/1X/1dc4b55a3ed407eb847d8e306b1fc4953dc77c08.png)

---

<div class="post-metadata">

### Author: ![j1elo](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/j1elo/32/1516_2.png) [@j1elo](https://openvidu.discourse.group/u/j1elo)
#### Post date: [September 28, 2020, 4:39pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/12 "2020-09-28T16:39:31Z")

</div>

Thanks, I still have to inspect the provided sample videos (I got the email now) and will let you know when I know something.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 29, 2020, 3:53am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/13 "2020-09-29T03:53:50Z")

</div>

@j1elo ok, Meanwhile just one more reference.

It seems there is some problem with MediaRecorder while recording in the Chrome. I’m guessing that the problem is MediaRecorder creating audio streams with overlaps.

Please see the Chrome bug which they have fixed. May be need to upgrade the latest Chrome version in Openvidu Recording Container.

> **[1102830 - 
 
 
 chromium -
 
 
 An open-source project to help move the web...](https://bugs.chromium.org/p/chromium/issues/detail?id=1102830#c7)**

[https://chromium-review.googlesource.com/c/chromium/src/+/2346292](https://chromium-review.googlesource.com/c/chromium/src/+/2346292)

---

<div class="post-metadata">

### Author: ![pabloFuente](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/pablofuente/32/2536_2.png) [@pabloFuente](https://openvidu.discourse.group/u/pabloFuente)
#### Post date: [September 29, 2020, 8:51am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/14 "2020-09-29T08:51:16Z")

</div>

INDIVIDUAL recording does not use the recording conainer. INDIVIDUAL recording is performed directly by Kurento Media Server dumping stream data into disk.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [September 29, 2020, 8:59am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/15 "2020-09-29T08:59:57Z")

</div>

Ok, You mean no MediaRecorder is involved for Individual Recording, It will directly write the incoming stream into disk.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [October 5, 2020, 12:57pm UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/16 "2020-10-05T12:57:04Z")

</div>

_Hello @j1elo Could you please let me know the root cause of this AV lag_ ?

---

<div class="post-metadata">

### Author: ![j1elo](https://yyz2.discourse-cdn.com/free1/user_avatar/openvidu.discourse.group/j1elo/32/1516_2.png) [@j1elo](https://openvidu.discourse.group/u/j1elo)
#### Post date: [October 26, 2020, 11:10am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/17 "2020-10-26T11:10:24Z")

</div>

The A/V sync issues **in Chrome** were caused by the sensitivity that Chrome player has to timestamp issues. Other players such Firefox are able to play the files correctly because it basically ignores the timestamp in the file.

The issue is caused by **gaps in the recorded timestamps**. For example, say that frames 4 and 5 are missing, the recorded file is like this:

1, 2, 3, 6, 7, 8, …

With frames 4 and 5 missing, Firefox assumes that between 3 and 6 there is a gap, and ignores the 6, 7, 8… bug Chrome doesn’t, so it accelerates the audio to accommodate the timestamps, and that’s why the audio comes ahead of the video.

We’ve improved this in Kurento Media Server, hoping it is a good enough solution: when there is a gap in timestamps, the next frames have their timestamp rewritten, so there are no gaps. Thus 6 would become 4, 7 would be 5, etc, and the recorded file would look like

1, 2, 3, 4, 5, 6, …

thus now Chrome plays the file correctly. This fix is already available in latest nightly builds of KMS, and will be released with 6.15.0 as soon as testing shows that there are no regressions or issues. And I believe it will be part of the next OpenVidu release too.

---

<div class="post-metadata">

### Author: ![rohit.roy](https://avatars.discourse-cdn.com/v4/letter/r/eada6e/32.png) [@rohit.roy](https://openvidu.discourse.group/u/rohit.roy)
#### Post date: [October 26, 2020, 11:29am UTC](https://openvidu.discourse.group/t/audio-video-not-in-sync-individual-recording/1912/18 "2020-10-26T11:29:18Z")

</div>

@j1elo great Thanks for the update. Next OV version will save our effort to recompile the recording stream to eliminate the AV syncing issue.
