Preview is pitch shifted and desyncs. Audio plays faster than video.
Describe the bug: When previewing a video in OpenShot, the audio is played noticeably faster than the video. This leads to desync over time while it is playing, and also the audio is pitch-shifted upwards. Hitting stop and play will re-sync the audio at the current position, but the pitch-shift remains and the desync will build again if left playing.
Steps to reproduce the behavior:
- Load a video project with both a video and audio component (works with both video+audio coming from one clip or from separate clips)
- Play the video project in the preview window at normal (1x) speed using the play button
- Listen to the playback and observe the pitch shift and desync issues
- Stop the preview and continue it
- Observe the audio starts synced at the correct place on restart, but the error builds up again
(Note it's fine when the video is exported, this is just the preview window that exhibits this problem).
Expected behavior: Audio is not pitch shifted Audio and video remains in sync
System Details:
- OpenShot Version: OpenShot-v2.6.1-dev-daily-9604-5776efd7-46255e46-x86_64.exe (64-bit) | July 20, 2022, 2:28 a.m.
- Operating System / Distro: Windows 10 21H2 19044.1865
Interesting. We're testing code currently to correct how we deal with time, especially when some frames or audio data is missing.
Do you a file, or a part of a file that you don't mind sharing, so I can see see how it behaves with our timing improvements?
Sorry for not getting back to you sooner.
I have created a test project with a couple of clips which have nice obvious motion for video and audio so the desync can be clearly heard.
I have also exported the video and taken a screen recording of the preview playing so you can see/hear what I see/hear if it doesn't come out like this at your end.
Even with just two tiny clips, it's an order of magnitude bigger than I can attach here, so I've put it on my google drive: https://drive.google.com/file/d/1o50FA3q6ulsoNAev_nUSHIa3RGK6_Mde/view?usp=sharing
Hopefully you can access this.
Please download and install the latest DEV Daily Build #9856 and give this a try. Let us know the result.
I'm seeing the same behaviour in OpenShot-v2.6.1-dev-daily-10153-854a3aa3-46255e46-x86_64.exe (64-bit) Nov. 4, 2022, 8:46 a.m.
System Details:
OpenShot Version: OpenShot-v2.6.1-dev-daily-10153-854a3aa3-46255e46-x86_64.exe (64-bit) Nov. 4, 2022, 8:46 a.m.
Operating System / Distro: Windows 10 21H2 19044.2130
Please verify your audio sample rate to ensure that OpenShot sample rate matches the Default audio device sample rate in Windows.
In OpenShot: Edit | Preferences | Preview tab and your "Default Audio Sample Rate" should be 48000. Mine is set to this.
In Windows 10 or 11: Start Control Panel | Hardware and Sounds | Manage Audio Devices | Click on your Default audio device | Select Properties | Click on Advanced. You will see the sample rate here. Change it to match OpenShot. I am running both Windows 10 & 11 on the same hardware and in both environments my setting is 24bit, 48000HZ (Studio Quality).
Please verify your audio sample rate to ensure that OpenShot sample rate matches the Default audio device sample rate in Windows.
In OpenShot: Edit | Preferences | Preview tab and your "Default Audio Sample Rate" should be 48000. Mine is set to this.
In Windows 10 or 11: Start Control Panel | Hardware and Sounds | Manage Audio Devices | Click on your Default audio device | Select Properties | Click on Advanced. You will see the sample rate here. Change it to match OpenShot. I am running both Windows 10 & 11 on the same hardware and in both environments my setting is 24bit, 48000HZ (Studio Quality).
This has resolved the issue for me, thank you! The previously set sampling rate in OpenShot was lower (didn't copy the exact value) and was never changed from the stable 2.6.1 default just in case that's helpful in any way. Again, thanks!
You are welcome! Yes, the original sample rate in OpenShot used to be 44100. However, this was due to the fact that Windows 10 used to be 44100. I read an article somewhere that this was causing other audio issues in Windows as well, and then with one of the Windows Updates the sample rate changed to 48000. This is when we started noticing audio issues within OpenShot and once discovered the developers changed OpenShot to 48000.
Really appreciate your feedback and hopefully this will help others as well.
Please feel free to close this issue.