[C++/Windows] Video Texture for Irrlicht (D3D,OpenGL)

Post those lines of code you feel like sharing or find what you require for your project here; or simply use them as tutorials.
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

[C++/Windows] Video Texture for Irrlicht (D3D,OpenGL)

Post by vi-wer »

hello,
I always wanted to know how to play videos in Irrlicht. Now I've made my own dynamic link library that loads videos (and images) to an Irrlicht texture.

here's a short example of how it's used:

Code: Select all

IVideoTexture *tex = createVideoTexture( "test.avi", device );
tex->play();
tex->getTexture(); //returns ITexture ptr
tex->playCutscene(); // play fullscreen video
//......
tex->drop();
and here's the link (version 0.4):
http://files.filefront.com//;7570242;;/

new files can be found here (version 0.4.5):
http://files.filefront.com//;7586087;;/

[UPDATE]
and another one (version 0.5):
http://files.filefront.com//;7604391;;/

OpenGL and Direct3D are supported.


[UPDATE2]
new release, new features (v0.6):
- some bugs fixed
- capture devices supported
- callback function
- documentation
- (not compatible with previous releases)

Get it here:
http://files.filefront.com//;7762666;;/
[/UPDATE2]

gcc + msvc version and example included.
Last edited by vi-wer on Tue Jun 12, 2007 2:40 pm, edited 5 times in total.
NicholasMag
Posts: 45
Joined: Fri Mar 09, 2007 8:06 pm

Post by NicholasMag »

so ive tested it out and it didnt work.

When opening up the example and testing it out the video does play. Actually it does something quite weird that i cant really describe so heres the pic.
Image
Is this because i do not have the codec?
RhavoX
Posts: 33
Joined: Tue Jul 04, 2006 7:27 pm

Post by RhavoX »

Strange... I have everything in order here.. Perhaps you should update your dx files and the video driver...
Teh Uber-Pwner xD
NicholasMag
Posts: 45
Joined: Fri Mar 09, 2007 8:06 pm

Post by NicholasMag »

my dx files are the most current and same with vid card. Ive never seen this happen before on anything but it seems to be showing parts of my desktop on it for i can see my stars from the torrent program and the blue accross the bottom for the start menu
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

You might try out one of the other existing video textures for Irrlicht.
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

try to replace "test.avi" with another video file or update your codec. it's coded with xvid.
I noticed problems with some codecs and uncompressed files, mostly the colors were wrong, but this ones new for me. I will check the code again.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Are you sure that the color formats are matched and you don't write into memory that does not belong to the texture?
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

The color formats shouldn't be the problem, it supports 3 different formats (16,24,32 Bit).
If the example doesn't work, it's probably a directshow codec problem, because it works for me.
The texture isn't clean when it's created, it's filled with some random stuff. Maybe the file is loaded but can't be played (because the codec is missing). When the example is started, it plays the video without the cubes, if it doesn't the video file probably can't be rendered to the texture and shows some random stuff.

I tried to play the same video coded with different codecs but the same color format (24Bit). The first one worked fine, the other one showed the right picture but the colors were ordered as vertical green, grey and red stripes. A problem with the color order?

Another problem I just noticed: it seem not to work properly when used in fullscreen mode.
I will try to fix that.
IPv6
Posts: 188
Joined: Tue Aug 08, 2006 11:58 am

Post by IPv6 »

tried example with original test.avi but without luck - the same mess (http://shadowedlands.net/images/vid.JPG) on screen, although player plays test.avi well. But replacing test.avi with another avi file fixes the issue!!! so it seems there is a bug in obtaining codec: video player plays it well where IVideoTexture can not play it

Is it hard to change the code to support flash movies played in texture?
flash movie can hold avi in it, so it is superior feature in many ways
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

I'm not sure but aren't there two different types of codecs existing? vfw and directshow codecs. So if the directshow codec is missing, the video will not be played in the example but still could be played in a player.

What do you mean by flash movies, .flv files? If so they work for me.

I've got ffdshow and a lot of codecs installed on my system, so I have no problems playing any video file with this lib.
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

What codec are you using for playing xvid files? Divx? Something from Ffdshow?I can't get any divx file to show within the test ap (same as the screens above). But sound is played so it should be something with the video codecs. Using a MS-RLE encoded avi everything works fine.

Maybe you could generate a "Something gone wrong; couldn't decode '<fourcc>"" being shown instead of the mess. Maybe you could add some kind of feedback and/or something like an optional "kill yourself once finished playing". :)

And yes, there are two possible types of standard codec types under Windows as far as I know.
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

Ok, I've wasted some of my time and made an update to the lib :? .
You can get it here:

http://files.filefront.com//;7586087;;/

Now it reports all errors and if the video file couldn't be loaded, the image will be shown instead (example only).

Further changes are:
- createVideoTexture() moved to IVideoTexture
- ms_example included
- example file loads an avi and mpg file
- ms_version works now

Hope this one works better.

@Ico:
DivX, Xvid and some other video files seems to be played using libavcodec on my computer.
Last edited by vi-wer on Fri May 25, 2007 8:59 am, edited 1 time in total.
Ico
Posts: 289
Joined: Tue Aug 22, 2006 11:35 pm

Post by Ico »

Spams "error: no driver or texture" but works partially (also opens an "active movie" window playing the movie but that should be a codec/driver setting and nothing affecting your program:

Image
vi-wer
Posts: 93
Joined: Sun May 20, 2007 7:15 pm
Location: Germany
Contact:

Post by vi-wer »

I made a new build, this one should work now:
http://files.filefront.com//;7597533;;/

I changed the whole DShow part and added support for OpenGL.
A screenshot of how it should look like is also included now.

It's now using two buffers + one texture for every IVideoTexture, so there's a lot of space necessary for high-resolution videos. These could also decrease the speed, especially in OpenGL.

The "render to texture" part is now performing color conversion.
Unfortunately there are currently only 2 formats supported (probably that's enough). I found some code in a DX SDK sample, but it didn't work, so I had to make my own. But I don't know if it's ok or could be optimized.
If you know where I can find some information on color conversion (RGB24>>A1R5G5B5) please tell me. Couldn't find something useful in google.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post by hybrid »

Just take the Irrlicht code. You'll find all necessary stuff in CColorConversion.cpp. There is just no user interface to those functions, yet.
Post Reply