电影帧还原播放.py

"""电影帧还原播放.py,本程序只是不断地播放图像,图像来源于电影视频输出的帧图。"""

import pygame
from pygame.locals import *
import time
import os

gametitle="周星驰审死官电影节简介_作者:李兴球"
pygame.init()
screenWidth,screenHeight=468,360
screen = pygame.display.set_mode((screenWidth,screenHeight))
pygame.display.set_caption(gametitle)

class Video():
    def __init__(self,folder):
        """参数:帧文件夹,启始位置,   """
        framesList=[]
        for item in os.listdir(folder):
            ext = os.path.splitext(item)             
            if ext[1] ==".png" or ext[1] ==".PNG" :               
               framesList.append(pygame.image.load(folder + os.sep + item))            
        self.framesList = framesList
        self.framesAmount = len(framesList)       # 帧数          
        self.frameindex = 0
        self.playend = False
        
    def play(self):
 
        if self.frameindex < self.framesAmount:
            screen.blit(self.framesList[self.frameindex],(0,0))
            self.frameindex = self.frameindex + 1

v1 = Video(os.getcwd() + os.sep + "周星驰出场")
clock = pygame.time.Clock()
running = True

while running:
    for event in pygame.event.get():
        if event.type==QUIT:running = False     
    v1.play()
    pygame.display.update()
    clock.tick(20)
    
pygame.quit()