VideoStreamPlayer delays audio when different window is in focus.

Godot Version

4.4.1

Question

I have a project, where I have a 17 minute long video playing in the background. The video is playing with the help of the VideoStreamPlayer node and works well, but when I focus on another window (click on it to do some stuff in it), for example my browser, the audio gets very delayed. Why is that, and is there some fix to that?

That’s your computer prioritizing your browser over the running Godot project because you changed focus. It is happening at an OS level. There are potential mitigation strategies such as pausing the video when the window loses focus, separating out the audio and playing it separately from the video but in synch to see if that solves the problem. Ultimately though, you don’t have control over the OS and prioritization of Godot. There are potentially some things you could do in the OS itself with code outside the project to prioritize your Godot project, but those would be outside the scope of Godot itself.

I do not think that is the case. The image runs just fine, its only the audio that gets messed up. Also many apps/games run audio in the background just fine, so its definitely on Godot. Also its only the audio from the video playing in the background, but other audios that are playing are just fine.

Ok, then I recommend trying to play a different audio file of some kind through AudioStreamPlayer and having the video running and see if that audio plays. It’ll give you another data point to work with.