1

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')
soundslikeodd
  • 1,078
  • 3
  • 19
  • 32
Kanna Kim
  • 383
  • 1
  • 3
  • 15
  • To convert the resolution of a video you need to use a kernel operation. The video library you are using does not support conversion of video resolution under the function call you are using. – kpie Jan 15 '17 at 04:35
  • oh yeah? is there any replacement for that one then? – Kanna Kim Jan 15 '17 at 04:38
  • I've never tried this myself, but `get_image_data()` should return a object that supports `rawimage.scale = 2.0` for instance. Could you try that? Assuming you just want to change the scale of a already successful image object. If that's not your main problem right now, this won't be relevant at all. But you've specified two questions/problems in your question, at least that's how i read it. – Torxed Jan 15 '17 at 11:44
  • I tried it and rawimage is stay same as 480x360 – Kanna Kim Jan 15 '17 at 19:02

0 Answers0