Game Development Community

Video Playback in Torque

by John Vanderbeck · 03/28/2004 (6:20 am) · 61 comments

Download Code File

This is pretty simple to install and use. I did not provide a patch because it is easy enough to apply without one. I didin't do any big writeups or anything on this, but if you have any questions just ask.

Note: This has not been tested on Linux or MacOS. It _should_ work, but I have no way to test. So if anyone can do that please let me know the results.

To apply this, backup your existing GuiAviBitmapCtrl source files, then simply extract the "GuiAviBitmapCtrl.cc/.h" files from the archive and place them in your engine/gui directory overwriting the existing ones.

Also included is a sample set of scrpits for playing a video file. Extract them to your example/starter.fps/client/ui directory. One of them will overwrite "startup.gui". Back it up first. The file "MoviePlayer.cs" has the video settings that you will want to set/change. At the very least you will need to alter the video file to some video file you have.

On Windows this plays using DirectShow so it will pretty much play anything you can play in Media Player. It will use the audio stream contained in the video file so there is no need for an external audio source.

On Mac or Linux this uses SDL/SMPEG for playback. This side of the code was pretty much unchanged except for enabling it to work.

The way this control is setup is odd. Instead of making a single set of calls which go through Platform:: and resolve to the appropriate calls on each platform, there is instead two seperate sets of functions in here. One set for Windows, which is what I changed to use DirectShow, and another set to use on Linux and Mac which uses SDL/SMPEG. To enable one set or the other you must appropriately set the #define's at the top of the files.
Page «Previous 1 2 3 4 Last »
#1
03/28/2004 (8:04 am)
If it uses DirectShow then it wont work on Linux or Mac.
#2
03/28/2004 (8:06 am)
Now just waiting for file :P
#3
03/28/2004 (8:07 am)
@Xavier
The way GG wrote this control is it has seperate sections for Windows and Mac/Linux. The Windows section used Video for Windows, the Mac/Linux used SDL/SMPEG.

I simply replaced VFW with DirectoShow in the Windows side. Mac/Linux still use SDL/SMPEG. I just made some changes to enable them to work.
#4
03/28/2004 (12:13 pm)
Great stuff, Ive been looking for this sort of thing for a while now. Now we to will be able to have cool animated introduction sequences (UT2K4/Dungeon Siege are prime examples) and great CG driven stories.

EDIT: the download doesn't seem to be working anymore... ?_?
#5
03/28/2004 (12:32 pm)
I'm not sure what the deal is on that. I guess the file hasn't been moved into the right spot on GG or something. I'll upload it to our website. Give me a few minutes.
#7
03/28/2004 (5:35 pm)
Sometimes you have to re-upload the files
#8
03/28/2004 (7:08 pm)
cool. I reuploaded it and it works now.
#9
03/28/2004 (8:37 pm)
Does it work for Mac /Linux EDIT: Sorry i'm just making sure
#10
03/29/2004 (5:53 am)
@Crhis, like I stated above, it _should_ but I have no way to test it. Someone will have to set the #defines for linx/mac, compile it, and test it.
#11
03/29/2004 (11:55 am)
Thanks John! This is very useful. I am trying to play a movie during the loadingGui. inbetween missions. Any suggestions on how to play a movie in other locations than just at the start of the game?

I'll keep working on it.

Thank you again.

Ryan
#12
03/29/2004 (1:51 pm)
I used your scripts and adjusted them so that I can now view my movie during the loading gui. This is a wonderful resource.
#13
03/30/2004 (9:54 am)
Glad you got it working :)
#14
04/02/2004 (9:46 am)
John:

After playing a movie in full screen mode the game window minimizes. This doesn't happen when I am running in window mode.

Any ideas?
#15
04/02/2004 (10:48 am)
Not off the top of my head, but i'll take a look at it later on.
#16
04/05/2004 (2:40 pm)
I tried integrating this resource with my own project and am having difficulty getting any video file to run. I'm attempting this on a windows XP machine with a minimally modified torque engine, and when the play command is invoked the screen just remains black and seems to get stuck somewhere in the starting process.

These are the steps I followed -
copied "GuiAviBitmapCtrl.cc/.h" files to the appropriate location

copied "startup.gui" and "MoviePlayer.cs" to the right places and included their exec call in the main.cs script so they get included

Changed the movie path to an existing movie. I tried this with several movie types (all of which play in media player) .mpg, and a couple different .avi formats. They all seemed to hang.

Is there something that needs to be setup first before a movie will play that is setup in the example fps version of the scripts and not the files included in this resource? Or any other insights? Thanks.
#17
04/06/2004 (6:06 am)
@Ryan
I can reproduce the problem but I honestly can't figure out why its doing it. If I manage to figure it out i'll be sure to post.

@Joe
Its hard to say what could be the problem there. Thorw a few breakpoints into the control is make sure the basic functions are getting called, especially onWake();
#18
04/10/2004 (5:03 pm)
When the game engine starts and the intro gets played.. the video is smaller then the screen and white space gets put in the empty spot.. not sure whats cuasing this..

any ideas?
#19
04/10/2004 (8:35 pm)
John: I haven't gone back to work on the video playback stuff yet, but I will probably start looking at it in depth again in the coming week. Thanks for your input. I will also let you know if I figure out what's causing the problem of minimizing the window after playback.
#20
04/11/2004 (5:13 am)
@RedCore
The "Video Window", IE where the video will be rendered is sized to the size of the control you place. The video itself however is played keeping its original aspect ratio. so if the control is a different aspect ratio than the video than it could very well have unrendered space. Though that should show up as black not white, it could be your problem.
Page «Previous 1 2 3 4 Last »