[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
Re: [pygame] Array2d fails with movie_renderframe
Mmm, interesting, according to the documentation, the screen is a surface. I had tried to render to a surface, but then the image was never displayed (I had not tried to get the array). Now that you suggested, I tried again, I still can't see the video, but the array has information. I guess I need to tell the display to render that surface, but I still haven't found how (I'll take another look). This is a great advance indeed! Thanks.
Here is my new code:
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)
w, h = movie.get_size()
size = w, h
screen = pygame.display.set_mode(size)
screen2 = pygame.Surface(size)
movie.set_display(screen2, Rect((0, 0), size))
def play():
i = 0
frame_number = 0
while(1):
frame_number = movie.render_frame(i)
frame = pygame.surfarray.array2d(screen2) #copies
print frame
## I also tried by adding a call to display.flip()... I guess that is not the way, it didn't work
if frame_number < i:
break
i = i + 1
movie.rewind()