problems with ogv video

Started by kursh, Sat 05/10/2024 08:50:02

Previous topic - Next topic

kursh

Hi i made the an intro for my game.

First in mpeg, then i convert to ogv.. the video its perfect in windows sound and image syncro.

The thing is when i use PlayVideo in AGS, the video goes faster than the sound.. or the sound is slower (its not syncro). I tryed with ogv in 30 fps and 25 fps.. and windows plays it perfect but not AGS...

i used www.freeconvert.com

some clues? thanks

carlos.

Crimson Wizard

This happened before, was reported couple of times.

I was going to check this out, but did not find much at the time, maybe I might try again. I still have someones video which demonstrates the problem.

My suspicion was that AGS uses an old decoding library that cannot handle certain video properties, and thus gives video frames at the wrong rate, but idk if that's exactly so.
It's just that some videos play properly and others not.

kursh

#2
Thanks... i've readed someone has convert mpeg to ogv with VLC, i have tried but.. nothing vlc cant export correctly in my case... its really anoying...

im going to "build" the game and execute normally in windows (maybe executing the game compiled works..)

tested: Doesnt work (audio sounds 2 o 3 seconds later than should ...) :___(

Khris

I recommended VLC, which has always worked fine for me. What exactly do you mean by "can't export correctly"?

kursh

#4
in vlc i convert to ogg, video codec theora, audio codec vorbis... the result didnt play this morning.....

but now i make another one conversion and i saw that the exported file is .ogg, i changed to .ogv and now is working in ags but without sound!.

i select audio codec Vorbis (if i select "same audio track original" doesnt works neither)

and other thing is the quality of the conversion is not good (i put in video bit rate 25000 kb/s)


kursh

Quote from: Khris on Sat 05/10/2024 15:48:22I recommended VLC, which has always worked fine for me. What exactly do you mean by "can't export correctly"?

could you say how exactly do you convert? i start from a .mp4 video "Códec: H264 - MPEG-4 AVC (part 10) (avc1)" (maybe is the problem)

Rik_Vargard

Do you use fades in or out or fades to black in your video editing?

For what I experienced back then when talking about this in the beginners forum is this:
It's just me but at this point of my "testing ogv in AGS" : it feels like AGS doesn't like black screens.

If you have black screen parts you might notice that in AGS, those are somewhat "ignored", which makes the video "go faster" than the audio.
I used different converters so I don't think those are the problem.

So, the black screens was my last observation before I moved on, and had to make three different files (Video,Music,SFX) and then go back and forward from editor to AGS to place the sounds and music until I got somewhat what I wanted in AGS.

I now use AGS v3.6.1 (Build 3.6.1.23) and haven't tested it again, yet, but that time will come. :-D

Khris

Quote from: kursh on Sat 05/10/2024 17:05:51could you say how exactly do you convert? i start from a .mp4 video "Códec: H264 - MPEG-4 AVC (part 10) (avc1)" (maybe is the problem)
In my tests I don't really mess with the settings, just pick Video (Vorbis) and hit the button. Plus, if the ogv file plays fine in VLC, the issue is with AGS and needs to be fixed there.

I don't really have experience here; I simply knew that the free and very good VLC can convert video files, so recommended that instead of online conversion services with file size limits, etc.

Crimson Wizard

Quote from: Khris on Tue 08/10/2024 06:52:33Plus, if the ogv file plays fine in VLC, the issue is with AGS and needs to be fixed there.

AGS uses particular library to decode, if that library does not support certain codec or settings, then it won't be able to play the video properly, or at all. So settings may matter. I do not know the acceptable range of settings though.

kursh

Sorry i didnt saw your answers. thanks to all.

Quote from: Rik_Vargard on Mon 07/10/2024 17:14:21Do you use fades in or out or fades to black in your video editing?


yes Rik_Vargard, i made the intro in after effects and i used a fade out at the end... only at the end (the sounds go slower from the beginning) whatever.. im going to try something different.. or export another format from what to use VLC to get final Ogv...

its sad, all is working perfect for me but this... :D

thanks all

eri0o

The sound decoding in AGS implementation is not done from libogg, but instead using SDL_Sound, which has a different implementation inside. This is done because we do decode the video images through the traditional Xiph library but pass the sound through the AGS sound system - this is for better sound control in our system, not in ags4 we have decoding multiple videos and other things supported there for video.

Anyway, my guess is you are hitting something that can be an issue in SDL_Sound, if it would be possible to get the video file, I could split the audio through a different program and run on SDL_Sound alone (without AGS) to try to figure it out what is happening.

Crimson Wizard

#11
Quote from: eri0o on Fri 11/10/2024 15:37:21The sound decoding in AGS implementation is not done from libogg, but instead using SDL_Sound, which has a different implementation inside. This is done because we do decode the video images through the traditional Xiph library but pass the sound through the AGS sound system - this is for better sound control in our system, not in ags4 we have decoding multiple videos and other things supported there for video.

This is not true, the video's sound is decoded by the libogg libvorbis (apparently), and only played by our general sound output (MojoAL).
SDL_Sound library is not used in case of video.

You may see the sound frame retrieval here:
https://github.com/adventuregamestudio/ags/blob/0d6194bff20633eca557793829738909131cff59/Engine/media/video/theora_player.cpp#L175-L191

Crimson Wizard

@kursh , @Rik_Vargard , could any of you please make a short video that demonstrates this problem?
I have an old Rik_Vargard's video, but it's pretty long and has lots of stuff happening in it, it's difficult to understand at which point the problem appears, so not very convenient for a test.

Ideally, it could be a video with visual cues (visual element appearing/dissapearing/changing) synced with certain points on sound track, like beats.

I am interested what the actual problem is that results in video-sound desync:
- is it that the sound is playing literally slower, like slower tempo.
- is it that sound is played with pauses.
- is it that video frames are changing too fast, more frequently than required.

eri0o

That's unexpected, why is the mpeg audio decoding code disabled there? This means the only type of audio track supported is strictly ogg - additionally, the libraries can't be the issue since they are the same libraries used by VLC.

Crimson Wizard

#14
The Theora video decoding was mostly untouched in many years, with the exception of small fixes.
The process of retrieving and decoding data is controlled by APEG library, everything happens inside of it. This is a very old library, and may have limitations, and, in theory, there may be cases that it simply does not know how to handle.
In order to decode an audio using SDL_Sound, for example, we would need to split the process into sound packet read and decoding steps. I suppose it might be possible to hack this inside APEG. But at the same time it may be beneficial to get rid of APEG and write a completely new video decoder, which will use SDL_Sound either directly, or through some interface.

Quote from: eri0o on Fri 11/10/2024 16:46:11why is the mpeg audio decoding code disabled there?

I have no idea, it may be a remains of times when MP3 was under a patent.


kursh

#15
Quote from: Crimson Wizard on Fri 11/10/2024 16:41:43I am interested what the actual problem is that results in video-sound desync:
- is it that the sound is playing literally slower, like slower tempo.
- is it that sound is played with pauses.
- is it that video frames are changing too fast, more frequently than required.

the 3rd one option i think whats happening because the sound is good tempo (not slower) video goes faster than music and effects.

I solved it yesterday... a video without sound, and then the sound in an independient mp3 file, i play it in a channel just before the PlayVideo (with "10" flag) and solved. It works now perfect for me. thanks.


Crimson Wizard

I'd like to figure out what is happening, and look for a possible fix, that's why I've been asking for a test video with such problem. If we manage to fix it, then users won't have to stumble on this, or separate audio from video.

kursh

Quote from: Crimson Wizard on Sat 12/10/2024 14:15:09I'd like to figure out what is happening, and look for a possible fix, that's why I've been asking for a test video with such problem. If we manage to fix it, then users won't have to stumble on this, or separate audio from video.

sorry. yes, i'll send you the video.

Crimson Wizard

#18
I received this video, and can observe the problem, where video is running faster than it should.

But I also noticed that there's a noise in the sound playback, which is not present when playing with a regular video player. I don't know if these two issues are connected or not.

EDIT: I found a previous topic by Rik_Vargard:
https://www.adventuregamestudio.co.uk/forums/beginners-technical-questions/ogv-video-images-going-faster-than-the-mucic-in-ags/

Rik_Vargard's video was 24 FPS, kursh's video is 25 FPS, idk if that matters.

EDIT2: I've been comparing first 5 seconds of intro, because that's roughly the time that makes the title text go upwards beyond the screen.
In AGS these 5 seconds are played roughly in 3.5 seconds, for some reason.

I have few proposals:
1. Video lies about its FPS (but then, how does the video player do it right?).
2. Video contains some "filler" frames that are supposed to be interpreted as "repeat previous frame", but the decoder in AGS ignores these.
3. Video frames are tagged with timestamps, i.e. playback is not supposed to rely on times calculated from FPS, but use each frame's timestamp instead.

Crimson Wizard

#19
It's curious, I tried the same video with the SpriteVideo plugin that uses a different TheoraPlayer library, and it seems to have same effect as AGS, with faster video playback.

There must be something specific in how the video is encoded, which standard theora playing lib cannot handle.

EDIT:
Since I have very little idea what to look at in OGG Theora, I will try downloading VLC player's source code and find how it interprets this video's parameters...

EDIT2:
Another curious thing: i tried to convert original video to Theora + OGG type using VLC itself, and the resulting video has exact same problem now...

SMF spam blocked by CleanTalk