Video plays very slowly

Started by Zrezal, Tue 03/06/2025 18:37:01

Previous topic - Next topic

Zrezal

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?

Crimson Wizard

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?

Zrezal

The AGS version is 3.6.2.
The video has been encoded with Shotcut with these characteristics: bitrate 12M, resolution 1920X1080.

Crimson Wizard

#3
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.

Zrezal

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.

Crimson Wizard

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.


Crimson Wizard

#6
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" (a 640x480 game) has videos with following parameters:
- 640x480
- Framerate: 13 fps
- Bitrate: 1 to 1.5 Mbps (varies between videos)

Crimson Wizard

#7
I found another example in recent "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).

Zrezal

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.

Crimson Wizard

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?

Zrezal

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.


Crimson Wizard

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.


Zrezal

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.

Crimson Wizard

#14
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.

Zrezal

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.

Crimson Wizard

#16
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.

SMF spam blocked by CleanTalk