Video is playing faster than audio

Started by ClearlyBrogan, Wed 06/12/2023 10:14:26

Previous topic - Next topic

ClearlyBrogan

hi, I have added a video to my game (ogv) but the video itself always plays faster than the audio in it, i cant figure out why. anyone come across this problem?

Crimson Wizard

#1
Hello, similar problem has been reported a small time ago:
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/ogv-video-images-going-faster-than-the-mucic-in-ags/

But I have not found time to look into this yet.

I do not recall hearing about this problem from older times. Either something got broken in the recent version of AGS, or there's certain properties of OGV that accidentally cannot be played correctly by the engine.
EDIT: the person who reported this earlier was using AGS 3.5.1, so probably this problem was potentially there for a long time.

eri0o

@ClearlyBrogan , it may be useful for later to have some additional information, like AGS version and a copy of the video if possible - and if it can be shared or not. With this would be easier to create a proper issue to track this down.

ClearlyBrogan

Hi, I just came off my pc after tearing my hair out for over an hour. Once I'm back on I will check my version and give video details.
Closest fix I could find was having the video and audio play as separate files but I wasn't sure if there was a way to skip audio on key press/click as there is with the video. And even then it would probably skip them separately. If so, it's the only thing I could find to sync up the vid and audio. Noone wants an unskippable intro cutscene now do we? Haha

eri0o

@ClearlyBrogan of course, when you have the time, it would be nice to have the video so we can run it in ags using a debugger to figure it out was going on.

But in alternative solutions, there is a  video plugin here, it won't use apeg and instead uses a different way to play video/audio for the Theora/Ogg format. It's currently available for Windows/Linux/Android

Crimson Wizard

#5
Quote from: ClearlyBrogan on Wed 06/12/2023 12:08:43Closest fix I could find was having the video and audio play as separate files but I wasn't sure if there was a way to skip audio on key press/click as there is with the video.

Yes, there is a way to stop audio by command.
https://adventuregamestudio.github.io/ags-manual/AudioChannel.html
There's no guarantee that the audio will be in sync with video if played on its own though.



Quote from: eri0o on Wed 06/12/2023 13:45:59But in alternative solutions, there is a  video plugin here, it won't use apeg and instead uses a different way to play video/audio for the Theora/Ogg format.

This plugin currently does not support playing audio. It does not have any sound output coded, and engine API does not provide any means to start audio playback using custom data either.

EDIT: I tried some experiment, and there seem to be a solution to support audio through asking engine to play it. Not fully certain how reliable this is, but it was a formal success in my test.

Crimson Wizard

#6
So, I completely forgot about this issue, but something I realized while experimenting with video playback is that currently AGS stores framerate as a integer, which may cause it to loose precision. E.g. videos sometimes have weird framerate like 29.97, and saving that as an integer would convert it to 29, loosing ~1 frame per second.
(I think this should be fixed in an upcoming version 3.6.1.)

I wonder if something similar happens here too... but maybe this is a separate problem.

While I remember about this, I should finally check out the video that @Rik_Vargard posted in another thread.

Rik_Vargard

#7
I export my videos at 30fps so it could be some frames problem but I'm not sure; I didn't think about that. (but that's just me). :P

I first thought it was the "empty spaces" in the video editor (which are exported as black in the movie) that did that so I added black images but that didn't work.

That's why as for now, I think that it has to do with how AGS reads "full black screens".
AGS seems to bypass it (or "ignores" it) and jumps fast forward to when there's "colours" again.

So right now I use two techniques:

The simple one is to play the video with no sound (use 11 at the end not 21);
Play the music in AGS and end the music when the video ends.

Now, if you have soundFX and/or scenes where the scene and the music really have to be synchronized at that particular moment in the timeline,
I had to adapt to how AGS reads the file. Think of it as your final monitor.

And then go back and forth with "adapting in the editor > export > convert > read in AGS, and so on until all the timings are right in AGS.

That's where I'm at for now. :P

Cheers!




Crimson Wizard

Quote from: Rik_Vargard on Sat 24/02/2024 11:51:27I export my videos at 30fps so it could be some frames problem but I'm not sure; I didn't think about that.

The video that you linked in that other forum thread ("End Credits 01") appears to be 24 fps. This may be found by checking Media Info in a video player program.

Rik_Vargard

Quote from: Crimson Wizard on Sat 24/02/2024 12:06:47
Quote from: Rik_Vargard on Sat 24/02/2024 11:51:27I export my videos at 30fps so it could be some frames problem but I'm not sure; I didn't think about that.

The video that you linked in that other forum thread ("End Credits 01") appears to be 24 fps. This may be found by checking Media Info in a video player program.

Ah yeah sorry, in my new game they're at 30 fps

SMF spam blocked by CleanTalk