Showing VLC output on a PyGame subsurface?
I'm working on an experiment where people watch a video while at the same time use a joystick to rate the video, using PyGame and the VLC bindings. This is the basic setting:
I created two subsurfaces for watching (left) and rating(right). The problem is that I cannot think of a way to play the video on the pygame subsurface on the left. I know the VLC bindings can output the video to a window given its window id, but I wonder if it is possible to output the video to a pygame surface (or subsurface).
I know pyglet can get the image data and show the image by using pygame.image.frombuffer().
Something like this
def draw(self, (width, height), surface, (x, y),fps): @self.window.event def on_draw(): # Convert the Pyglet video player's image to a Pygame surface tex = self.player.get_texture() raw = tex.get_image_data() pixels = raw.get_data('RGBA', raw.width * 4) video = pygame.image.frombuffer(pixels, (raw.width, raw.height), 'RGBA') video_scaled = pygame.transform.scale(video, (width, height)) # Blit the image to the screen surface.blit(video_scaled, (x, y)) pygame.display.update()
So I wonder if there is a similar way for VLC bindings?