[visionegg] Displaying raw movies

Hello,

We have movies in raw format (64x64 pixels x 30000 frames, written in
consecutive uint8 bytes) that we'd like to play at 200 Hz. What would be
the most efficient way to load and display such a movie in VisionEgg?
(we've written a C extension for this, but I'm wondering if there's a
simple and efficient method within Python/VisionEgg)

Right now, I'm using the texture.py demo as a template, with my own
presentation loop. The best way I've found so far is the following
(omitting some stuff):

####################
f = open("movie1", 'rb')
data = Numeric.array(f.read(30000*64*64)) # read in and convert to Numeric
movie = Numeric.reshape(data,(30000, 64, 64)) # reshape it
frame = movie[0,0:64,0:64] # pick out the first frame
temp_texture = Texture(frame)
checkerboard = TextureStimulus(texture=temp_texture,
                               position=(400,300),
                               anchor="center",
                               mipmaps_enabled=0,
                               size=scaled_size,
                               texture_min_filter=gl.GL_NEAREST,
                               texture_mag_filter=gl.GL_NEAREST,
                               )

texture_object = checkerboard.parameters.texture.get_texture_object()

framenum = 0
# main loop
while not quit_now:
   framenum += 1
   texture_object.put_sub_image(movie[framenum,0:64,0:64]) # update frame
   # blah blah blah...
   swap_buffers()
#######################

This runs quickly with no frame drops. The only catch is that the initial
step of converting the file contents into a Numeric array is very slow,
about 30 s for this 120 MB file (the reshaping step, however, is
instantaneous). I've noticed that using numarray instead of Numeric is
much faster in this respect, and takes only a couple of seconds for the
following:

f = open("movie1", 'rb')
movie = numarray.fromfile(f, UInt8, (30000,64,64))
frame = movie[0,0:64,0:64] # pick out the first frame
temp_texture = Texture(frame)

However, the last line gives me the following error:

TypeError: texel data could not be recognized. (Use a PIL Image, Numeric
array, or pygame surface.)

Is there any way to get Texture() to accept numarrays? Is there some
alternative to Texture() that I could use? Or, are there easier/faster
ways of displaying a raw movie using PIL or pygame?

Thanks,

Martin
======================================
The Vision Egg mailing list
Archives: http://www.freelists.org/archives/visionegg
Website: http://www.visionegg.org/mailinglist.html

Other related posts: