[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Array2d fails with movie_renderframe



Hello,

I have been trying to use pygame to access a video frame by frame and extract the pixel values.  The frame is correctly rendered.  However, numeric and numpy get an array of zeros when I try to get the info from the display.  Is this a bug or am I missing something?  The code I use is as follows:

import pygame, sys
from pygame.locals import *

filepath = "esponja.mpg"
pygame.init()
pygame.mixer.quit()
pygame.surfarray.use_arraytype("numpy")
   
movie = pygame.movie.Movie(filepath)
size = w, h = movie.get_size()
screen = pygame.display.set_mode(size)
movie.set_display(screen, Rect((0, 0), size))

def play():
  i = 0
  frame_number = 0
  while(1):
    frame_number = movie.render_frame(i)
    frame = pygame.surfarray.array2d(screen) #copies
    print frame
    if frame_number < i:
      break
    i = i + 1
  movie.rewind()

I am using ubuntu 8.10.
Thanks

--
"Todavía vivimos vuestros abuelos, aún es poderoso nuestro lanzadardos; conquistadores y sabios de tiempos antiguos: ¡Volved a vivir!"
  Canto de los mexicas a Tlacaélel y Axayácatl, en su única derrota.