Skip to content

Commit

Permalink
add example
Browse files Browse the repository at this point in the history
  • Loading branch information
Tee Jung committed Mar 28, 2018
1 parent 6856d19 commit f26c4a6
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions example/viewer.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import pygame
from PyDemux import Video

import time


def main():
width, height = -1, -1
screen = None

pygame.init()

video = Video.open('/Users/tee/Downloads/interview.mp4')

while 1:
im = video.get_frame()
if im is None:
break

if im.size != (width, height):
width, height = im.size

pygame.display.set_mode((width, height))
screen = pygame.display.get_surface()

image = pygame.image.frombuffer(im.tobytes(), im.size, "RGB")
screen.blit(image, (0, 0))
pygame.display.flip()

pygame.event.get()
time.sleep(1)


main()

0 comments on commit f26c4a6

Please sign in to comment.