Python-Ogre Theora performance issues ( precaching )


15-04-2009 10:01:52


firstly thanks for the great plugin, I found it very useful in a recent project.

I know this is probably not the best place to ask, but I've been working with the python-ogre devs to try and resolve an issue we're having with the latest version of the theora plugin, which has been included in the newest version of python-ogre. The previous version worked fine, albeit suffering from performance issues which have already been discussed here. However, the latest update has seen the playback speed for ogg video drop dramatically ( on my system and several others at least ), and we can't work out why. The theora plugin is compiled from the current SVN version, and wrapped as a python-ogre module in the same way as all the other modules ( with py++ ).

I tried grabbing the SVN of ogrevideo a couple of days ago and it worked absolutely fine, the playback rate is perfect, so it must be a problem at the python wrapping stage, but none of us have any idea what that could be. I've tried logging the precached frames as the movie plays, and it starts at about 10, but decreases to zero very quickly ( this is with the sample clip that comes with ogrevideo ).

Just wondering if anyone here could shed any light on the issue? ( long-shot I know ! )

many thanks,


15-04-2009 22:30:15


I'm actually working on python-ogre for this plugin as well, it's just not high on the priority list at the moment.

The reason is probably because I've been doing extensive work on the SVN, which introduced some breaking changes and performance issues, which have mostly been resolved now.

I don't suggest using the latest svn version for python-ogre because, as you can see, it's not stable enough.
I plan to release an alpha version somewhat soon, which is the first version that could be wrapped.

alternatly, you can just use an older revision for wrapping.


16-04-2009 08:58:23

Hi Kreso,

thanks for the reply - I actually managed to fix the issue I was having by messing with the plugin source a bit ( below is the one change I made to TheoraVideoManager.cpp ). I just tweaked the way decoding jobs are doled out to threads, and its suddenly working fantastically ( 1280x720 source, 7mbs playing at a constant 30fps, with python-ogre running at over 650 fps in the background, with the buffer constantly full and spitting out frames nicely! ), just without sound at the moment.

Here's the change in case its of any use to you ( its just in the mClips iterator ):

TheoraVideoClip* TheoraVideoManager::requestWork(TheoraWorkerThread* caller)
if (!mWorkMutex) return NULL;
TheoraVideoClip* c=NULL;
static unsigned int cnt=0;
unsigned int i;
ClipList::iterator it;
if (mClips.size() == 0) c=NULL;
//for (it=mClips.begin(),i=0;i<cnt;it++,i++)
for (it=mClips.begin(); it != mClips.end(); it++)

if ((*it)->mAssignedWorkerThread == NULL)

if (cnt >= mClips.size()) cnt=0;
return c;
} // end namespace Ogre



16-04-2009 09:10:36

Cool. your change is in the svn now. that hack was there temporarily because I was testing with only one video.

I'm not sure how that would fix the slowdown though? I recently introduced a 2 millisecond wait after each decoded frame which increased the performance dramatically, maby you just updated your working copy and that solved the problem :D


16-04-2009 12:43:52

cool :)

yes I'm not sure how that affected the performance either really ... though honestly, i compiled it straight from svn and was getting very poor performance, just did that change and it all started working great! Though, I was getting issues on shutdown occasionally after making that change, seemed like threads weren't joining properly after the change.

I'll do another checkout now and see what happens