Theora plugin questions - HD Video


04-02-2009 18:43:59

Hi folks,

I've been trying to get HD video playing in Python-Ogre and am hitting a bit of a wall. ( it was one of those moments at work when your boss says, 'nearly there, now we just need to add full hd video and we're laughing..' )

So, I've got my video playing the same as the theora demo, and successfully added it as an overlay to my app, but the framerate was a bit shonky with a 720p source. Since that point I managed to implement what the theora wiki recommends, and do the YUV->RGB conversion in a pixel shader, however it doesn't work.

I'm pretty sure the shader is correct as its pretty much identical to the theora example, and i get no compile errors. I'm using the material script here: modified to look like:

material SimpleVideo
fragment_program_ref std_vert
vertex_program_ref yuv_to_rgb_cg
texture_source ogg_video
filename clip.ogg
precache 16
play_mode play
output yuv

With this material I just get a solid green, but by tweaking the shader I can see that something is being passed to it, but its not the video source.
So my questions are:

Basically all I need to do is find a way to output just the raw YUV source from theora?

Alternatively - is OgreFFMPEG still around?

Alternative even to that, can anyone think of a good quick workaround? the deadline train is approaching :) I have already tried shelling out to VLC which works fine if my app is windowed, but causes a world of pain if its fullscreen ( which of course, it needs to be :( ), with plenty of DirectX problems, and once the accursed BSOD.

any help very much appreciated,



04-02-2009 22:19:55

Have you looked at the "new" plugin I know it works with Python-Ogre just haven't yet implemented it myself...

Ogreffmpeg is still in the SVN, just needs an older version of ffmpeg....

Also if it's windows only you could go with the ogredshow which uses directX which is also in the SVN...



05-02-2009 06:26:22

Ogreffmpeg is still in the SVN, just needs an older version of ffmpeg....

Someone posted an update on the main forum for using the ffmpeg videoplayer
class with more recent versions of ffmpeg. It uses swscale so probably is GPL AFAIK. ... 2&start=25

There's a patch here if you are interested: ... tid=916690


05-02-2009 09:21:24

Thanks for the replies!

my other problem is that I dont have a PO build environment set up either ( although I have a new PC to unpack which could be made into a PO building machine ).

So in laymans terms, how could I go about compiling the new plugin into a build of PO? Do I have to build it all from scratch, or can I just build the theora module on its own?

many thanks,


05-02-2009 13:24:13

Do you have a sample video I can use to test with that shows the problems ?

I've updated the ffmpeg module with dermonts patch so that works again and am having a quick look at the dshow (directx) -- then tomorrow I'll update the Theora and be able to send you a new set of binaries etc..



05-02-2009 20:20:37

Hi Andy,

thats great news, my gratitude knows no bounds!

Unfortunately, I can't provide the exact clip I was using as its commercially sensitive. However I can say, I converted it from a H.264 Mov @ 720p 60fps using ffmpeg2theora. I just realised I haven't yet tried dropping the framerate, so I'll give that a try tomorrow.

In the meantime I checked out the PO SVN this morning in an attempt to set up my own build environment, I think I've got all the dependencies and VS Express 9.0 setup, so I'll just re-checkout PO tomorrow and see what I can do ( which probably won't be much as I'm not good with C++ compiler warnings let alone scons or py++, but hey! )

If you have the spare time to do another binary with ffmpeg, I'd be even more grateful than I am already.



06-02-2009 04:18:31

Have a look in the unstable section on source forge -- an updated set of modules that implement ogredshow and ogrevideoffmpeg modules for you to try..

The demos are still in the svn and seem to work ok



06-02-2009 10:14:01

Fantastic! thanks Andy. :D

Can report that ffmpeg is working, and performance is certainly better than my theora efforts. I think our source footage is a bit unreasonable at 60 fps so we're going to try various video formats, compressions and framerates today. Will report whichever works best.



06-02-2009 12:18:20

Slight update -

we're now using a half-size source and dropped encoding settings ( 30fps @ 5.0mbps ). Which is running at a very healthy 700 fps. One oddity is that turning vsync on slows the framerate of the video playback, its still quite smooth, but appears to be slowed to about 75% of original speed. Its strange because it should have plenty of spare cpu headroom to do the decoding considering it runs so fast with vsync off. Still using ffmpeg, might give ogreDShow a try later. Frame size seems to be the most important element though, a 30fps @ 5mbps @ 1280x720 source struggles to hit 20 fps in ogre, whereas half size is well over 600fps.

Also a slight update to the ffmpeg demo - as far as I can tell, theres no need to set the video material every frame, just once will do ( although the video material is not quite right until at least one frame is rendered ):

def frameStarted(self, frameEvent):
global runTime
runTime+= frameEvent.timeSinceLastFrame*1000
self.videoPlayer[0].refresh( int( runTime ) )
#print dir(self.videoPlayer[0])
tex = self.videoPlayer[0].getVideoTexture()
if self.start and tex:
self.material.getTechnique(0).getPass(0).getTextureUnitState(0).setTextureName( tex.getName() )
self.start = False


06-02-2009 13:13:58


slightly embarrassed now, it seems that with a reasonable source ( 640x360, 30fps, 5mbps ), theora is absolutely fine. I think we're going to stick with it now, as we also need some audio in there which ffmpeg can't do ( as far as I know ? )

anyways, thanks again andy, and sorry for wasting your time! :oops:


09-02-2009 16:03:24

The theora video plugin in python ogre is still the old one. The new one, the one I'm working on performs much much better. It precaches frames and uses shaders to decode YUV data wherever possible. We're using it for our commercial project and it works like a charm.

I will make a python ogre wrapper as soon as possible, which should then get included in the next binary release of PythonOgre.


09-02-2009 18:51:59

Thats good to hear, thanks Kreso.

At the moment, the current plugin is doing well enough for our demo version, but we may have need of the updated plugin when we hit the usability testing phase. The final product will be using proprietry libraries for engine and video playback though.

I wish I could say more about what we're doing ( perhaps after we launch ), as its pretty high profile ( names you will no doubt be familiar with ), and could give PO some serious kudos! :D

anyway, thanks again all for the continued help and support! we wouldn't be getting very far without it I'm sure.. :)


09-02-2009 22:56:43

Well, follow the news, when the new plugin gets wrapped, We'll let you know.

if you should urgently require the plugin before that, drop me a line, I'll send you a 'hacked' version we're using for our project.