Playing video files in Torque? [SOLVED]
by Andrew H · in Torque Game Builder · 11/13/2011 (5:55 pm) · 15 replies
Is there a way to play video files in a T2D game? If so, how would I do so - and please direct me to a tutorial, or if there isn't one, tell me how - please.
About the author
I do everything for my game company. Including the legal stuff.
#3
11/18/2011 (5:59 pm)
What format is it that you must convert it to? Ogg Vorbis? If so, how do you do so without losing picture data?
#4
11/20/2011 (12:23 pm)
Hello? Little help? I thought .ogg was an audio format - no picture data.
#5
11/20/2011 (1:00 pm)
From the very first result in Google when searching for 'ogg':Quote:Like I mentioned in my response, I use VLC Player to do any conversions I need. Link
The Ogg container format can multiplex a number of independent streams for audio, video, text (such as subtitles), and metadata
#6
11/20/2011 (3:21 pm)
Ah. I am using VLC Player as well, but it comes out as just audio.
#7
11/20/2011 (3:32 pm)
Oh, never mind. I figured it out.
#8
11/20/2011 (6:01 pm)
Erm, now I have a new problem - there's no sound. Does that have to be done separately or something?
#9
11/21/2011 (1:19 am)
No, it should play audio track too, as long as it's ogg audio. Look for player report in the console.
#10
11/21/2011 (12:50 pm)
I don't understand. If it's just Ogg audio T2D crashes. If it's an Ogg video file it doesn't play any sound. Why?
#11
There is a link to the file Patric posted above, and here's one I used:
http://en.wikipedia.org/wiki/File:2008_Indy_500_video.ogv
Both are 100% TGB-compatible I guess. Would be great if you could tell us what's printed in the console when you trying to play these.
Also, audio track from video file is played via channel 0 (channel is the same thing as 'type' field of the AudioDescription), make sure it is not muted.
11/22/2011 (2:09 am)
It plays audio tracks, as a part of video file of course. You need theora video and ogg vorbis audio packed in one ogv-file (ffmpeg2theora produces files with that extension, though I've seen video files with .ogg extension too).There is a link to the file Patric posted above, and here's one I used:
http://en.wikipedia.org/wiki/File:2008_Indy_500_video.ogv
Both are 100% TGB-compatible I guess. Would be great if you could tell us what's printed in the console when you trying to play these.
Also, audio track from video file is played via channel 0 (channel is the same thing as 'type' field of the AudioDescription), make sure it is not muted.
#12
So it gets sound.
My video outputs this:
And it doesn't get sound.
But when I convert it, I choose the Ogg Theora + Vorbis, and it has sound in VLC player.
11/22/2011 (8:49 am)
Okay, with Patrick's video, it outputs this:Ogg logical stream 74aa is Theora 400x304 29.97 fps video - Frame content is 400x300 with offset (0,4). Ogg logical stream 5e7 is Vorbis 2 channel 22050 Hz audio.
So it gets sound.
My video outputs this:
Ogg logical stream 2675068 is Theora 640x480 29.97 fps video - Frame content is 640x480 with offset (0,0).
And it doesn't get sound.
But when I convert it, I choose the Ogg Theora + Vorbis, and it has sound in VLC player.
#13
11/22/2011 (8:54 am)
I figured it out! I convert it to *.ogv instead of *.ogg, and it works! Well, I guess experimentation is the mother of success a lot of times in this field.
#14
I'm Vickie btw, it's a pleasure to meet you Laura, I've noticed these torque boards are a bit cold and un-personal so it is always good to meet someone like yourself ;) Mike is like us too, you should say "hi" to him sometime.
Always~
11/22/2011 (9:40 am)
that is so true Laura! And thanks for posting your steps to success, I have been watching this post from the time you started it and I'm happy to see you accomplish what you started out to do. This will be a great reference for anyone wanting video in their games!I'm Vickie btw, it's a pleasure to meet you Laura, I've noticed these torque boards are a bit cold and un-personal so it is always good to meet someone like yourself ;) Mike is like us too, you should say "hi" to him sometime.
Always~
#15
06/09/2013 (5:52 am)
To let the video play all by itself then continue into the game without the user pressing Stop use this code. But you need to know exactly how long it plays in seconds * 1000 milliseconds...MyVideo.setFile("game/data/video/example.ogg");
// the video needs to quit after set time - in this case it's 10 seconds or 10000
schedule(10000,0,"stopVideo");
Torque Owner RollerJesus
Dream. Build. Repeat.
Add this to whatever gui you would like to show the video:
new GuiTheoraCtrl(MyVideo) { profile = "GuiDefaultProfile"; horizSizing = "relative"; vertSizing = "relative"; position = "0 0"; extent = "1024 768"; minExtent = "8 2"; visible = "1"; done = "0"; stopOnSleep = "1"; backgroundColor = "0 0 0 255"; }; new GuiButtonCtrl(stopButton){ profile = "GuiButtonProfile"; horizSizing = "relative"; vertSizing = "relative"; class= "introVideo"; position = "0 0"; extent = "25 25"; minExtent = "8 2"; visible = "1"; Command = "stopVideo();"; };Then play the video using:MyVideo.setFile("game/data/video/example.ogg");And stop it using the following, which is linked to the button in the above code:function stopVideo() { echo("stopping video"); MyVideo.stop(); }Here is a link to the video that I used to test so you can reference for settings, etc.I usually create animations in Flash or After Effects, the convert using the free version of VLC Player - Google it.