How to play video in viewport/screen

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
Post Reply
camiloforero3
Gnoblar
Posts: 2
Joined: Sun Mar 22, 2015 7:54 pm

How to play video in viewport/screen

Post by camiloforero3 »

Hello everyone

I started using Ogre a couple of weeks ago, doing the tutorials and getting used to the structure. I want to use Ogre for an Augmented Reality like application, and for that one of the first things I need to do is to have a video playing on the screen background, and render whatever objects I might have on top of it. I've been searching in google and in these forums but I haven't found any clear answer to this, at most I can play the video over a texture but I don't know how to do that on the screen itself.

Eventually I will do this on a live video feed, but for demonstration purposes a prerecorded video should be enough.

Thank you for your help!
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: How to play video in viewport/screen

Post by xrgo »

Hello!! there is a plugin for that
Theora Plugin:
http://www.ogre3d.org/addonforums/viewf ... 1b2f217e1c

but I have no experience with it.

What I did one time is that I capture a webcam input, had to process it with openCV, then I fill a dynamic ogre texture, with a code like this one:
http://www.ogre3d.org/tikiwiki/tiki-ind ... c+textures

EDIT: I couldnt find my code but here is something related (opencv to ogreTexture)
http://www.ogre3d.org/forums/viewtopic. ... 13#p429477
frostbyte
Orc Shaman
Posts: 737
Joined: Fri May 31, 2013 2:28 am
x 65

Re: How to play video in viewport/screen

Post by frostbyte »

at most I can play the video over a texture but I don't know how to do that on the screen itself.
you can render the scene to a texture( rtt ) instead of a window, then you can blend the scene texture with the video texture as you wish using compositor or overlay material, you can also use skyBox/skydom material with the video texture but the perspective will be disorted
EDIT: I couldnt find my code but here is something related (opencv to ogreTexture)
viewtopic.php?f=5&t=64913#p429477
regarding the opencv code mentioned above...
no need to videoCapture->retrieve(frame, CV_CAP_OPENNI_BGR_IMAGE);
and then do copy frame->data to the texture pixelBox buffer

you can just do
mPixelBuffer->lock(Ogre::HardwareBuffer::HBL_DISCARD); // for best performance use HBL_DISCARD!
pDest = static_cast<Ogre::uchar*> (mPixelBox.data);
frame->data = pdest; //set opencv frame data pointer to the texture pixelBox HardwareBuffer
videoCapture->retrieve(frame, CV_CAP_OPENNI_BGR_IMAGE); //this will decode the captured frame directly to the texture hardware buffer( much faster )

its also better to use syedhs method of double buffer( texture ) with threading http://www.ogre3d.org/forums/viewtopic. ... 13#p429240
this way opencv decoding to texture will not damage the rendering loop performance

you also have scrawl's ffmpeg plugin http://www.ogre3d.org/forums/viewtopic.php?f=5&t=81934 which is very good
but for AR i would use openCV since it has the best multii-platform/vendor camera support and it can also use ffmpeg as a decoder backend...
the woods are lovely dark and deep
but i have promises to keep
and miles to code before i sleep
and miles to code before i sleep..

coolest videos link( two minutes paper )...
https://www.youtube.com/user/keeroyz/videos
camiloforero3
Gnoblar
Posts: 2
Joined: Sun Mar 22, 2015 7:54 pm

Re: How to play video in viewport/screen

Post by camiloforero3 »

Thank you! seems there is a lot of work ahead

The Theora plugin seems to be kind of dead at the moment, hasn't been touched since 2013 and the developer is not answering questions, I'm stuck at a compiling error and can't seem to go on. I will try the rtt route then, and see what happens
Post Reply