Pyglet Image Upside-down Example Fix
I was doing some video processing in python today and I couldn't find any good answers on how to save rightside-up images using pyglet. Apparently pyglet saves them upside-down by default. Here's my solution: #load the video video = pyglet.media.load("myVideo.wmv")Â
#get the first frame frame = video.get_next_video_frame()Â
#get the image data of the first frame imageData = frame.get_image_data()Â
#get the pixels of the frame but invert the pitch pixels = imageData.get_data(imageData.format,imageData.pitch *-1)Â
#set inverted pixels to the image dataimageData.set_data(imageData.format,imageData.pitch,pixels)Â
#save the image imageData.save("myVideo_capture.png")Â


















