I want to adjust rawimage's width and height
By doing some research I could find out that I can simply just do
rawimage.width = (value whatever width I desire)
rawimage.height = (value whatever height I desire)
but then another problem rolled in. It gives me the following error:
video = pygame.image.frombuffer(pixels, (rawimage.width, rawimage.height), 'RGBA') ValueError: Buffer length does not equal format and resolution size
I couldn't find out how to resolve that issue. Is there anyway to resolve that issue?
The code:
import pygame
import pyglet
window = pyglet.window.Window(visible=False)
player = pyglet.media.Player()
player.queue(pyglet.media.load(".\\music_folder\\music_vid/servant_of_evil.mp4"))
player.play()
@window.event
def on_draw():
#We have to convert the Pyglet media player's image to a Pygame surface
global player
rawimage = player.get_texture().get_image_data()
print "rawimage "+str(rawimage)
pixels = rawimage.get_data('RGBA', rawimage.width *4)
video = pygame.image.frombuffer(pixels, (rawimage.width,rawimage.height), 'RGBA')
#Blit the image to the screen
gameDisplay.blit(video, (0, 0))
pygame.display.update()
while True:
pyglet.clock.tick()
for window in pyglet.app.windows:
window.switch_to()
window.dispatch_events()
window.dispatch_event('on_draw')