(Movie)Texture - Using StringIO or some other buffer as data

Hello all,

I’m making a simple 3D media “collection” using Panda3D, now the idea was to implement the option to watch YouTube videos directly, while you’re ‘downloading’ them.

Now I only have one problem: MovieTexture.read() (which is basically Texture.read()), can only read files. The problem with this is that on Windows, you can’t write and read to the same file at the same time, so the media player will run out of data, very fast.

I was wondering if anyone had ideas how to do it? (I could use something like a StringIO, where when I’m downloading I’ll keep appending data to it)

Thanks,

William van Doorn

Yes,
I’ve run into this problem quite a few times myself. MovieTexture is great when it works in it’s structured way but fails when you want to do something fancy like video streaming.

There are a few ways you can do this:
Pointer textures. This is a still pretty undocumented but is in the main 1.7.0 build. There’s a blog entry about it with an attached sample for getting textures onto the graphics card quickly and it would be a movie.

Your second option is to use Awesomium to access the youtube videos directly. There’s a few forum entries about a Swig wrapped Awesomium module. There is also currently in the source tree a half working (i’m currently working on it) version of Awesomium using a WebTexture class.

In either case, it’s not a simple thing to do.

Thanks,

Since this YouTube streaming is just one of the small things of my 3D media collection I think I’m going to use pointer textures. I’ve downloaded the example but since there is some C++ code I’m still a bit confused.

After reading the Python code, using a cStringIO seems the best idea, while I’m ‘downloading’ the YouTube video I can write data to it right away:

imageBuffer.write(...)

Then on the other hand, do I need to have a task running every frame of the video to read new data? Like:

imageBuffer.read(1024)

And then ‘send’ it to the graphics card?

Is this the right approach or did I misunderstood something?

Thanks,

William van Doorn

I think that cStringIO is python construct (implemented in c) but the panda3d C++ knows nothing about it. There are panda3d streams you might play around with.

Bei, pointer textures are dangerous and Awesomium does not work all that well multi platform. I would think we would need to figure out a file streaming approach that works then resort to hackery.