Theora video and audio sync
by Jack Stenner · in Torque Game Engine · 10/24/2005 (7:53 pm) · 9 replies
I have a GuiControl that contains a GuiTheoraCtrl that loads and plays a movie when the dialog is triggered. Within this interface, there are multiple buttons that also trigger videos within the same GuiTheoraCtrl. The problem is that after the first movie plays, the audio of any subsequent movie is out of sync (delayed). As a test, I removed the movie that automatically plays when the dialog is opened, so that movies are played only after selecting a button, but the same thing still happens. The first movie has synchronized audio, and subsequent movies, don't.
Screenshot of gui - each button loads a different movie:

Anyone else seeing this? Any ideas of things to try?
Thanks,
Jack
Screenshot of gui - each button loads a different movie:

Anyone else seeing this? Any ideas of things to try?
Thanks,
Jack
About the author
#2
Is MagicalTrevor in synch?
10/25/2005 (10:19 am)
Do you have the most recent OpenAL libs? This makes a HUGE difference in how robust the sound layer is.Is MagicalTrevor in synch?
#3
For some reason, I find that very, very funny.
I haven't played with more than a single movie, and not a large one at that. I wanted to play with it, though I have moved away from the direction of FMV to in-game cinematics for space concerns.
10/25/2005 (10:52 am)
Quote:Is MagicalTrevor in synch?
For some reason, I find that very, very funny.
I haven't played with more than a single movie, and not a large one at that. I wanted to play with it, though I have moved away from the direction of FMV to in-game cinematics for space concerns.
#4
Just for reference, MagicalTrevor is the class that keeps track of where in the audio track we are, and generally makes the video & audio play in synch. (It's ever so clever.) I figured that MagicalTrevor was just as good a name as AudioVideoSynchTrackerThing; the comments make it obvious what it does.
So if you're getting synch issues it's PROBABLY related to what Trevor is doing, unless it's an underlying bug in OpenAL or something else.
10/25/2005 (10:56 am)
:PJust for reference, MagicalTrevor is the class that keeps track of where in the audio track we are, and generally makes the video & audio play in synch. (It's ever so clever.) I figured that MagicalTrevor was just as good a name as AudioVideoSynchTrackerThing; the comments make it obvious what it does.
So if you're getting synch issues it's PROBABLY related to what Trevor is doing, unless it's an underlying bug in OpenAL or something else.
#5
Ben: I am using OpenAL 1.2 on OSX and OpenAL 1.1 on the PC. 1.1 is the latest that I could find for the PC, at least it's more recent than the one included with 1.4rc2 (that I have). The same thing occurs with both OSs. I don't get any MagicalTrevor errors. You ask if MagicalTrevor is in sync.... Is there a way to check? I took a look at the class in theoraPlayer.cc, see functions called advanceTime, getListSize and postBuffer, but don't know what they would tell me.
10/25/2005 (6:04 pm)
Jon: Thanks I'll give those suggestions a try.Ben: I am using OpenAL 1.2 on OSX and OpenAL 1.1 on the PC. 1.1 is the latest that I could find for the PC, at least it's more recent than the one included with 1.4rc2 (that I have). The same thing occurs with both OSs. I don't get any MagicalTrevor errors. You ask if MagicalTrevor is in sync.... Is there a way to check? I took a look at the class in theoraPlayer.cc, see functions called advanceTime, getListSize and postBuffer, but don't know what they would tell me.
#6
I'm having problems with Theora playback that sound like they are related (but not identical) to the ones described above. Hopefully it will be ok to mention them here. If not, I'll edit out and start a new Theora wierdness thread. :L
1) when I go from a video clip with sound to another without sound, the sounds from the first clip continue to play for a few seconds while the second video is running.
2) videos with sound continue to play even after the parent dialog (and ctrl) is closed. I usually have to play a short, silent video before closing to kill the previous sounds. If I don't do this, and the sound from the first video is still playing when I try to exit Torque, then the app hangs indefinitely while trying to save out user prefs (according to the console). When I alt-tab out and close the app from the console-window title bar, I don't get a "Not Responding" error like I might have expected.
3) videos with sound sometimes get hung up on the first few frames or play very s-l-o-w-l-y. Clicking them again or playing another movie first then going back usually fixes playback. I've noticed that it occurs almost every time I change screen resolution and then try to play a video with sound. Res changes and silent videos work just fine. Unfortunately, whenever this stutter effect does occur, then it is always a prelude to . . .
4) Torque crash on exit. Again, issues 3 and 4 always seem to happen together.
I apologize if I've posted to the wrong thread, but it sounds like our problems may be coming from the same source. (um, no pun intended).
10/25/2005 (8:27 pm)
Hi guys,I'm having problems with Theora playback that sound like they are related (but not identical) to the ones described above. Hopefully it will be ok to mention them here. If not, I'll edit out and start a new Theora wierdness thread. :L
1) when I go from a video clip with sound to another without sound, the sounds from the first clip continue to play for a few seconds while the second video is running.
2) videos with sound continue to play even after the parent dialog (and ctrl) is closed. I usually have to play a short, silent video before closing to kill the previous sounds. If I don't do this, and the sound from the first video is still playing when I try to exit Torque, then the app hangs indefinitely while trying to save out user prefs (according to the console). When I alt-tab out and close the app from the console-window title bar, I don't get a "Not Responding" error like I might have expected.
3) videos with sound sometimes get hung up on the first few frames or play very s-l-o-w-l-y. Clicking them again or playing another movie first then going back usually fixes playback. I've noticed that it occurs almost every time I change screen resolution and then try to play a video with sound. Res changes and silent videos work just fine. Unfortunately, whenever this stutter effect does occur, then it is always a prelude to . . .
4) Torque crash on exit. Again, issues 3 and 4 always seem to happen together.
I apologize if I've posted to the wrong thread, but it sounds like our problems may be coming from the same source. (um, no pun intended).
#7
www.garagegames.com/mg/forums/result.thread.php?qt=36287
11/09/2005 (6:40 am)
Jack...In case your interested I got this fixed.www.garagegames.com/mg/forums/result.thread.php?qt=36287
#8
11/10/2005 (9:27 pm)
Thanks I'll try the fix!
#9
11/10/2005 (10:04 pm)
Thanks for the follow up, Jackie!
Jon Wilsdon
Default Studio Name
It seems like whenever a video plays all the way to the end of the video file that the next video gets its audio out of sync. One thing you can try is to stop the video just before it is supposed to end (just call stop() on the GuiTheoraCtrl) and then start the next video and see if it is still out of sync. If this fixes it, then a workaround is to keep track of how long the video is and schedule a stop() to be called right before the video is supposed to end. I have looked at the differences in code vs. what gets called in the script with no luck so far in tracking down why this works.
Another thing you can try is to Canvas.pushDialog() the GuiTheoraCtrl on before you play a video and Canvas.popDialog() the control off after the video is done. I haven't actually tested this method though.
Let me know if either of these two work for you.
Jon