Hi, Everyone!

I tried to get the length of the VideoStreamWebm, but could not find a function as useful as AudioStream's GetLength().

How do you guys get the length?

Thanks.

This is a simple source code, but it is enough for Godot.

VideoStreamWebm stream = new VideoStreamWebm();
stream.File = "path/to/movie.webm";

VideoPlayer player = GetNode<VideoPlayer>("VideoPlayer");
player.Stream = stream;
player.StreamPosition = 0.0f;

float video_length = ???; // <- This is what I want to know!

Does anyone know how to get the length of a VideoStream?

Unfortunately, it doesn’t currently seem possible to get the length of a video using the VideoPlayer node or similar. It appears to be a recurring issue that comes up (based on Google searches at least) but there doesn’t seem to be a solution yet.

If the video is not dynamic, you may want to hard-code the lengths. Something else you could try is splitting the audio from the video and then use the get_length function in the AudioStream and use that for the length of both the audio and video.

Thanks for answering!

I see that this is an issue that has been discussed several times in the past. I found a class called VideoStreamPlaybackWebm that had get_length, so I custom built GodotEngine. This worked well and I was able to get the length of the video.

However, I thought it was an API that had some problems and was not exposed, so I decided not to use it (seek() is empty!). .

Hopefully I'll be able to get the length of the video soon.

Thanks.

2 years later