Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: Zrezal on Tue 03/06/2025 18:37:01

Title: Video plays very slowly
Post by: Zrezal on Tue 03/06/2025 18:37:01
Hi.
I'm trying to put a video in my game, but when it comes to playback the video is slower than the audio.
I have tried with .Ogg and .Ogv formats, with identical results.
I have tried with 7 second and 1 minute videos and the same thing happens.
PlayVideo("Intro.ogv", eVideoSkipNotAllowed, 0);
How can I solve this?
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Tue 03/06/2025 19:06:15
There have been a similar report:

https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/sound-of-my-video-has-a-delay-that-is-getting-worse-every-second/


Unfortunately, the previous user did not provide any further information.

We need to know some details about video format and how did you make the video (which software, export settings).
If possible, could you upload a short video example that has this problem?
Also, which version of AGS are you using?
Title: Re: Video plays very slowly
Post by: Zrezal on Tue 03/06/2025 19:13:49
The AGS version is 3.6.2.
The video has been encoded with Shotcut with these characteristics: bitrate 12M, resolution 1920X1080.
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Tue 03/06/2025 19:42:44
Quote from: Zrezal on Tue 03/06/2025 19:13:49The video has been encoded with Shotcut with these characteristics: bitrate 12M, resolution 1920X1080.

That's a high resolution video; is your game also 1920x1080? What is the video's framerate (fps)?

If your video's fps is high enough (like 60 fps), then there's a real chance that AGS cannot handle this fast enough, because it's streaming video from the file realtime and not only has to load and decode a frame, but also has to convert each frame into the texture.

Could you upload any random short video that you've made and that does not work (previously you mentioned a 7 seconds video)? I'd like to check out what is happening with it.
Title: Re: Video plays very slowly
Post by: Zrezal on Tue 03/06/2025 20:28:06
I am modifying the bitrate to 2M and it seems to almost match the video to the audio.
I don't understand why AGS is having trouble playing a simple video.
Even if I reduce the video to 320x240, it still happens the same.
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Tue 03/06/2025 20:55:25
Quote from: Zrezal on Tue 03/06/2025 20:28:06I don't understand why AGS is having trouble playing a simple video.

I cannot answer this question without having a video that I may do tests with.
The two guesses I have is:
1. It does not process the video fast enough
2. AGS uses a pretty old video decoder library. It's possible that it cannot process certain video format properly.

Title: Re: Video plays very slowly
Post by: Crimson Wizard on Tue 03/06/2025 21:09:32
I haven't done many tests of videos in AGS, so I don't have enough experience to tell which parameters to use.
Quickly checked couple of AGS games that had video cutscenes in them.
For example, "Zniw Adventure" (https://store.steampowered.com/app/904750/Zniw_Adventure/) (a 640x480 game) has videos with following parameters:
- 640x480
- Framerate: 13 fps
- Bitrate: 1 to 1.5 Mbps (varies between videos)
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Tue 03/06/2025 21:16:52
I found another example in recent "Old Skies" (https://store.steampowered.com/app/1346360/Old_Skies/), it has following videos:
- 1920 x 1080
- Framerate: 24 - 36 fps
- Bitrate: 25 - 34.0 Mbps

But these are very short (few seconds only).
Title: Re: Video plays very slowly
Post by: Zrezal on Tue 03/06/2025 21:20:59
I can't give you a video because I am constantly changing parameters and recompiling it.
Tomorrow I will post more results by lowering the bitrate and fps a bit from 24 to 20.
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Tue 03/06/2025 21:23:47
Quote from: Zrezal on Tue 03/06/2025 21:20:59I can't give you a video because I am constantly changing parameters and recompiling it.

Well, you could post any of them that did not work?
Title: Re: Video plays very slowly
Post by: Zrezal on Wed 04/06/2025 09:52:40
It can be seen that the video at the beginning is unbalanced video and audio. In the introduction animation it is unbalanced later on.
The only solution I see is to do as with the menu, create a gif.

Title: Re: Video plays very slowly
Post by: Crimson Wizard on Wed 04/06/2025 10:43:22
Zrezal, I'm sorry if I was not clear, by "posting a video" I meant uploading it somewhere as a file which I could download and test in the engine.

I need to actually see the video file, see its parameters, see what the engine is doing.
Title: Re: Video plays very slowly
Post by: Zrezal on Wed 04/06/2025 11:45:38
Ok.
https://www.mediafire.com/file/mocsphsf5f2plma/3x3+Eyes+Kyuusei+Koushu+S.zip/file (https://www.mediafire.com/file/mocsphsf5f2plma/3x3+Eyes+Kyuusei+Koushu+S.zip/file)
Title: Re: Video plays very slowly
Post by: Zrezal on Wed 04/06/2025 19:40:44
I have already solved it. I reduced the resolution from 1080p to 640X480, so videos under 7 seconds play without problems.
The bad thing is that I have to keep editing.
I think this AGS problem should be worked on and it has been going on for too long.
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Wed 04/06/2025 20:06:46
I tried the project that you linked above, and I see a different problem where video plays in a good rate (or so it seems), but sound is delayed by 1-1.5 seconds. This may be a general desync issue. Of course I cannot tell if this is the original video, or it's already an edited one, so maybe the situation with it is different from the earlier one that you tried.

(On a side note, I have a question whether the choice of 1920x1080 resolution is optimal for the game, as both the video and backgrounds that I see in this project were probably converted from lower res.)

Quoteso videos under 7 seconds play without problems

What about videos longer than 7 seconds?

QuoteI think this AGS problem should be worked on and it has been going on for too long.

Unfortunately a number of problems in AGS have been going for too long, as it's been developed by a tiny number of people working in their spare time. Videos are not used often in games made by AGS, so the video playback support has always been low priority.

Apparently, I will have to look into video playback closely this year.
Title: Re: Video plays very slowly
Post by: Zrezal on Thu 05/06/2025 09:14:26
Quote from: Crimson Wizard on Wed 04/06/2025 20:06:46I tried the project that you linked above, and I see a different problem where video plays in a good rate (or so it seems), but sound is delayed by 1-1.5 seconds. This may be a general desync issue. Of course I cannot tell if this is the original video, or it's already an edited one, so maybe the situation with it is different from the earlier one that you tried.

(On a side note, I have a question whether the choice of 1920x1080 resolution is optimal for the game, as both the video and backgrounds that I see in this project were probably converted from lower res.)

Quoteso videos under 7 seconds play without problems

What about videos longer than 7 seconds?

QuoteI think this AGS problem should be worked on and it has been going on for too long.

Unfortunately a number of problems in AGS have been going for too long, as it's been developed by a tiny number of people working in their spare time. Videos are not used often in games made by AGS, so the video playback support has always been low priority.

Apparently, I will have to look into video playback closely this year.

If they exceed 7 seconds, they start to get out of sync.
Title: Re: Video plays very slowly
Post by: Crimson Wizard on Thu 05/06/2025 13:26:13
Alright, since this is a clear observable problem, and I now have an actual video that demonstrates this, I'll address this now and try to fix this within one of the next 3.6.2 patches.