Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix VideoStreamPlayer seamless loop #77856

Merged

Conversation

kinami-imai
Copy link
Contributor

@kinami-imai kinami-imai commented Jun 4, 2023

Part of a group of three PRs (#77856 #77857 #77858) that solve godotengine/godot-proposals#264.

This PR enables seamless looping in VideoStreamPlayer nodes with connecting the on_finished signal to the play() function. Currently doing this will result in a blank frame due to the fact that the internal processing trigger only fires again on the next frame, which means the draw call on the current frame will draw an empty texture. With this change the texture is already updated with the newly started playback, which renders the first frame to the texture instead of leaving it blank, eliminating the one frame flash of transparency of the previous implementation.

Before (note the flash of background when the loop restarts):

before.mp4

After (no flash of background):

after.mp4

@kinami-imai
Copy link
Contributor Author

kinami-imai commented Jun 5, 2023

As requested in the contributors chat, here is an audio sample of the VideoStreamPlayer looping seamlessly (warning, might be loud).

Audio being looped:
https://github.com/godotengine/godot/assets/129700584/a56d3993-02d0-426c-8a67-8b6354263093

Resulting output from Godot:
https://github.com/godotengine/godot/assets/129700584/294d53e7-4f50-43d3-a296-0766f75df480

Note that depending on CPU load and complexity of the audio, it still might crack.

@kinami-imai kinami-imai force-pushed the videostreamplayer_seamless_loop branch from 9c53c31 to 270bc93 Compare June 5, 2023 19:18
@kinami-imai
Copy link
Contributor Author

Force pushing changes of @KoBeWi to keep git history clean 🙂

@YuriSizov YuriSizov merged commit b99a023 into godotengine:master Jun 6, 2023
@YuriSizov
Copy link
Contributor

Thanks! And congrats on your first merged Godot PR!

kinami-imai added a commit to kinami-imai/godot-docs that referenced this pull request Jun 6, 2023
As no workarounds are necessary to seamlessly loop videos since godotengine/godot#77856 got merged.
@letsgamedev
Copy link

Very nice! Waiting for this thing for like 4 Years to happen XD
Would it be possible to do this in Geodot 3 as well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants