ScreenRecorderLib icon indicating copy to clipboard operation
ScreenRecorderLib copied to clipboard

Screen recording Audio Sync issue

Open ranwer-dev opened this issue 2 years ago • 15 comments

I have tried recording google meet calls with it. In the beginning, audio and video remain in sync but after some time, the audio goes out of sync. Mostly Audio is ahead of the video. In the most recent recording, I did a 20-minute recording. The audio video was fine for the first 3 minutes and then the audio was ahead of the video.

These are the options that I use for recording

RecorderOptions.OutputOptions.RecorderMode = RecorderMode.Video;

RecorderOptions.VideoEncoderOptions.Framerate = 30;
RecorderOptions.VideoEncoderOptions.IsFixedFramerate = true;
RecorderOptions.VideoEncoderOptions.Quality = 80;
RecorderOptions.VideoEncoderOptions.Encoder = new H264VideoEncoder
{
	BitrateMode = H264BitrateControlMode.Quality,
	EncoderProfile = H264Profile.High
};

RecorderOptions.AudioOptions.IsAudioEnabled = true;
RecorderOptions.AudioOptions.IsInputDeviceEnabled = true;
RecorderOptions.AudioOptions.IsOutputDeviceEnabled = true;
RecorderOptions.AudioOptions.AudioInputDevice = (AudioDeviceComboBox.SelectedItem as AudioDevice).DeviceName;
RecorderOptions.AudioOptions.AudioOutputDevice = (SystemAudioDeviceComboBox.SelectedItem as AudioDevice).DeviceName;
RecorderOptions.AudioOptions.InputVolume = 1;
RecorderOptions.AudioOptions.OutputVolume = 1;

RecorderOptions.MouseOptions.IsMousePointerEnabled = true;

RecorderOptions.SourceOptions.RecordingSources = new List<RecordingSourceBase>
	{
		new DisplayRecordingSource(monitor)
		{
			OutputSize = monitor.OutputSize,
			Position = monitor.Position,
			RecorderApi = RecorderApi.WindowsGraphicsCapture,
			IsBorderRequired = false
		}
	};
}

ranwer-dev avatar Jan 25 '23 16:01 ranwer-dev

Was this with one of the releases, or compiled from the main branch? I pushed some fixes for audio drift issues a few days ago, but haven't made a new release yet. If the issues was with an older release, you can try the new changes from one of the automatic builds here if you wish.

sskodje avatar Jan 25 '23 21:01 sskodje

Yeah, I noticed that recent commit. I was using latest branch code.

ranwer-dev avatar Jan 26 '23 06:01 ranwer-dev

Do you know the sample rate and bit rate of your microphone and output device in windows audio settings? I'm guessing it has to be something about that, as i'm unable to reproduce.

sskodje avatar Jan 26 '23 12:01 sskodje

I was using a USB mic image

And Bluetooth headphone image

But I have experienced this out-of-sync issue with simple wired hands-free too when I was not recording System Audio.

ranwer-dev avatar Jan 26 '23 20:01 ranwer-dev

Thanks, that's very helpful. I can probably guess it's due to mixing input and output with different samle rates, as i've had some bugs with that before. I'll try to reproduce .

sskodje avatar Jan 26 '23 21:01 sskodje

Were you able to reproduce/fix this?

ranwer-dev avatar Feb 27 '23 19:02 ranwer-dev

Unfortunately i wasn't able to reproduce it on any of my hardware, so the issue is kind of stuck.

sskodje avatar Mar 01 '23 00:03 sskodje

I have a similar issue. Could this issue have been resolved? For the first 5 minutes after recording, the video and audio input are in sync. However, as the recording continues, it is out of sync. I am using version 3.1.2.

SID9-HoneyBee avatar Mar 28 '23 02:03 SID9-HoneyBee

I fixed some audio drift issues in version 5.2.0. You see if it fixes your issues.

https://github.com/sskodje/ScreenRecorderLib/releases/tag/v5.2.0

sskodje avatar Mar 28 '23 10:03 sskodje

No, the issue is still there. It goes fine for the first few minutes, but later System's Audio gets delayed from the video.

I fixed some audio drift issues in version 5.2.0. You see if it fixes your issues.

https://github.com/sskodje/ScreenRecorderLib/releases/tag/v5.2.0

ranwer-dev avatar Mar 28 '23 13:03 ranwer-dev

I fixed some audio drift issues in version 5.2.0. You see if it fixes your issues.

https://github.com/sskodje/ScreenRecorderLib/releases/tag/v5.2.0

I was afraid to migrate to version 5 while using 3.1.2. But I got it working yesterday. As a result of testing by applying version 5.2.0, it is confirmed that the audio drift issue has been resolved. Let's do a little more testing. Thank you very much.

I would like to ask an additional question regarding WebCam Overlay.

SID9-HoneyBee avatar Mar 29 '23 02:03 SID9-HoneyBee

As a result of testing by applying version 5.2.0, it is confirmed that the audio drift issue has been resolved.

@SID9-HoneyBee your issue was with microphone audio or System Audio? My System audio issue is still there.

ranwer-dev avatar Mar 29 '23 14:03 ranwer-dev

As a result of testing by applying version 5.2.0, it is confirmed that the audio drift issue has been resolved.

@SID9-HoneyBee your issue was with microphone audio or System Audio? My System audio issue is still there.

Haven't tested in many environments. However, in testing in four environments, all out-of-sync issues were resolved.

Migrated to version 5.2.0. That's it.

SID9-HoneyBee avatar Apr 02 '23 15:04 SID9-HoneyBee

I have observed the System Audio recording lag issue happens with Wiresless headphone. With builtin laptop speaker, it works fine.

ranwer-dev avatar Apr 03 '23 12:04 ranwer-dev

It's still a valid issue. When we are recording both microphone and system audio at the same time.

ranwer-dev avatar Jul 22 '24 12:07 ranwer-dev