PDA

View Full Version : [Streaming] Video on a texture - ?



Freelancer
03-04-2005, 02:16 AM
Hi everyone!

Have you seen Doom 3's videos on a "message boards"?

Any way of fast-projecting (?) an AVI to a texture?

Thanks in advance,

Dmitry.

T101
03-04-2005, 02:28 AM
http://nehe.gamedev.net/data/lessons/lesson.asp?lesson=35

yooyo
03-04-2005, 09:13 AM
Originally posted by Freelancer:
Hi everyone!

Have you seen Doom 3's videos on a "message boards"?

Any way of fast-projecting (?) an AVI to a texture?

Thanks in advance,
Easy.. Get DXSDK and find Texture3D example. Modify it by removing D3D stuff and just copy frame in some shared temp buffer. In main render loop check for new data and upload it to texture and render. Use some events and critical sections to synchronize access to shared temp buffer.

Use PBO to upload texture (if hw support it).

If you can't get smooth playback try to limit max fps in your engine (ie. insert Sleep(10) after SwapBuffers) to give chance to decoder to finish it's job.

yooyo

Java Cool Dude
03-04-2005, 09:27 AM
If you're using the NeHe tutorial, good luck playing back the sound...
yooyo, got a working example? I sorta have something up and running but since most of the videos these days come with different sound streaming coding, I have yet to get anything working with sound.
PS: Well I have something but I'm using an expensive hack to play the sound...

Cab
03-04-2005, 10:56 AM
I also modified the Texture3D example and it worked pretty fast.
In this example, as there is no sound rendered overloaded, it seems that the sound is played using the default sound device. So the sound works.
Another point: if you use PBO extension, it is only faster if your video decodes to BGRA. If you decode to RGB or BGR, using PBO is slower than not using it (at least in my experience in some computer configurations).
The NEHE example uses vfw instead of DirectShow and it is much more slower because you are calling the decode function every frame, even if there is no new frame in the video.
Also this example uses the DrawDibDraw that is very slow and is not necesary in most of the cases (if you know the format of the video and it is not a YUV or similar format)
The speed diference is really big. In the DShow example there is a callback that is called when a new frame is needed so you only update the texture when a new frame is decoded.
In the Nehe example, even with the DrawDibDraw call removed, you are decoding and updating the texture with the same data until the new frame comes which makes it really slow.

Hope this helps.

Java Cool Dude
03-04-2005, 10:59 AM
^
Sir, I would really appreciate it if you can send me some sample code showing a video working with sound in an OpenGL scene.
Thanks in advance :)

Cab
03-04-2005, 11:33 AM
For a limited time :)
You can download a quick and dirty modification of the Nehe example using the Texture3D DShow example.
http://www.abril.com.es/PlayVideo.zip

Note that you should have installed the DirectX SDK including the Extras that are in a separate download.

Also note that the example was made for a 512x256 video (the size of the texture) and assuming that the video is decoded in BGR. It was a quick test I made so I commented all the code that converts between formats but I left it on the code so you can take it back.

Hope this helps.

Java Cool Dude
03-04-2005, 11:50 AM
Who's the man? Cab's the man :D
Thanks for your help, I'll be taking a look at this later on and I'll try and provide some feedback :)

yooyo
03-04-2005, 01:49 PM
You can use GL_TEXTURE_RECTANGLE_EXT to keep texture memory. It works with PBO very smooth.

@cab
Your demo eats up to 80% of cpu time on my P4 2.8Ghz during decoding xvid 608x256 movie. Just add Sleep ( 10 ) in U1P_UpdateStats and cpu time will be ~5-10%.

yooyo

Java Cool Dude
03-04-2005, 06:19 PM
NVM...

Java Cool Dude
03-05-2005, 01:12 PM
I just wanna take a moment and send a big thank you out there for Cab; your sample code was really helpful in getting me all started.
I've been working on a faster and better version though in the past few hours and I should be able to put together a demo tomorrow and post it right here.

Cheers :)

Java Cool Dude
03-10-2005, 10:49 PM
Demo (http://www.realityflux.com/abba/C++/DVOpenGL/GLDV.zip)

Most formats, including WMV/ASF, supported :)
Early beta picture (hmm I wonder where have I bumped into something like that before :p )

http://www.realityflux.com/abba/C++/DVOpenGL/betaVideo.PNG

Nico_dup1
03-11-2005, 12:45 AM
Nice. Will you provide source code?

stanlylee
03-11-2005, 03:09 AM
I think you can use many decoder to decode the VIDEO to a 2d Image buffer.
you can use Windows AVI API . or use a opensource lib at sourceforge named "avifile".

and you also could use DirectShow . it is very easy to use . and you can copy most of the code from MSDXSDK .

here is a example. with source code

http://xreal.51.net/Game/projectvideodemo.htm

Java Cool Dude
03-11-2005, 03:34 AM
Originally posted by Nico:
Nice. Will you provide source code?Guilty as charged :D .
Look into AppUtils, DVTexture for the code relevant to this demo, and Application GLSL DV for the main files.

Source (http://www.realityflux.com/abba/C++/DVOpenGL/SXML%20Engine.zip)