Google

Video Playback

Discussion regarding the Managed .Net Wrapper for Ogre, MOGRE (http://sourceforge.net/projects/mogre)

Moderators: OGRE Team, MOGRE Moderators

Video Playback

Postby CrazyXBMax » Tue Feb 21, 2012 9:11 pm

Hi guys,

I have been working on a game engine for some time now and one major feature that it's currently lacking is video playback. I can use libvlc and the RenderWindow's handle to display fullscreen videos (splash screens, cutscenes) but I can't use it on a texture. All topics I found in this forum, are either very old or completely dead-end. I already tried converting to SWF and playing it with Makarui but I got 1. no sound and 2. no material (seems to be null?). Could somebody point me in the right direction (existing library, TheoraVideoPlugin with Mogre, writing an ExternalTextureSource)?

Thanks for your help.
CrazyXBMax
Gnoblar
 
Posts: 4
Kudos: 0
Joined: 13 Feb 2012
Location: Germany

Re: Video Playback

Postby CrazyXBMax » Thu Feb 23, 2012 9:14 pm

I found a way to use AForge.Video.FFMPEG to render a video into bitmaps. I use this function to convert it into an Texture:

Code: Select all
private static unsafe void ConvertBitmapToTexture(Bitmap image, string textureName, Size size)
        {
            try
            {
                int width = size.Width;
                int height = size.Height;
                using (ResourcePtr rpt = TextureManager.Singleton.GetByName(textureName))
                {
                    using (TexturePtr texture = rpt)
                    {
                        HardwarePixelBufferSharedPtr texBuffer = texture.GetBuffer();
                        texBuffer.Lock(HardwareBuffer.LockOptions.HBL_DISCARD);
                        PixelBox pb = texBuffer.CurrentLock;

                        BitmapData data = image.LockBits(new System.Drawing.Rectangle(0, 0, width, height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                        CopyMemory(pb.data, data.Scan0, width * height * 4);
                        image.UnlockBits(data);

                        texBuffer.Unlock();
                        texBuffer.Dispose();
                    }
                }
            }
            catch (Exception)
            {
            }
        }


But, this makes the application unresponsible after rendering about 2~3 frames. BTW, the image is given to the game code using events, is that a performance issue? I don't think this code is actually the big issue cause I have taken it from http://code.google.com/p/mogresdk/sourc ... Texture.cs.
CrazyXBMax
Gnoblar
 
Posts: 4
Kudos: 0
Joined: 13 Feb 2012
Location: Germany

Re: Video Playback

Postby Beauty » Sun Mar 04, 2012 7:40 pm

I wanted to point to the webcam demo of user smiley80, but you still found it.
Unfortunately I have no further idea. (I never tried to do something similar.)

Perhaps you can search/ask in the Ogre main forum.
It's not .NET, but perhaps they have ideas, which further techniques are possible.
Also you could search/ask in the Axiom forum.
Axiom is a port of Ogre to pure C#. If they have a solution for your needs, you have a good chance to do the same with your Mogre application.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1601
Kudos: 35
Joined: 09 May 2007
Location: Germany

Re: Video Playback

Postby CrazyXBMax » Mon Mar 05, 2012 7:26 pm

I think my current problem is converting the pixel formats between the Bitmaps I get from AForge and the Mogre Texture stuff. I also need to check whether my class design is fast enough. If I get something useful, I'll post it here.
CrazyXBMax
Gnoblar
 
Posts: 4
Kudos: 0
Joined: 13 Feb 2012
Location: Germany

Re: Video Playback

Postby Beauty » Mon Mar 05, 2012 8:05 pm

The Bitmap --> Texture conversion is a general question (not much Mogre specific.)
So you have good chances when you search/ask in the Ogre main forum. There are much more people than in our small sub cummunity.

Yes, if you find a solution, it would be nice to hear about.
Help to add information to the wiki. Also tiny edits will let it grow ... :idea:
Add your country to your profile ... it's interesting to know from where of the world you are.
IRC chat ... Mogre: irc://freenode/#mogre ... Ogre: irc://freenode/#ogre3d
User avatar
Beauty
OGRE Community Helper
 
Posts: 1601
Kudos: 35
Joined: 09 May 2007
Location: Germany


Return to MOGRE

Who is online

Users browsing this forum: No registered users and 2 guests