Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/289.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何让MoviePy iter_frames()以正确的速度播放?_Python_Time_Iteration_Moviepy - Fatal编程技术网

Python 如何让MoviePy iter_frames()以正确的速度播放?

Python 如何让MoviePy iter_frames()以正确的速度播放?,python,time,iteration,moviepy,Python,Time,Iteration,Moviepy,我正在尝试用tkinter创建一个视频播放器,它在MoviePy中播放一个视频剪辑对象。该对象有一个iterable“iter_frames()”,它在每次迭代中返回一个numpy数组和帧。以下是播放该剪辑的循环: for frame in self.video.iter_frames(): if self.stop: sys.exit() while self.paused: pass

我正在尝试用tkinter创建一个视频播放器,它在MoviePy中播放一个视频剪辑对象。该对象有一个iterable“iter_frames()”,它在每次迭代中返回一个numpy数组和帧。以下是播放该剪辑的循环:

        for frame in self.video.iter_frames():
            if self.stop:
                sys.exit()
            while self.paused: pass
            img = Image.fromarray(frame, 'RGB')

            img = img.resize((round(img.width / 1.5), round(img.height / 1.5)), Image.ANTIALIAS)
            tkImage = ImageTk.PhotoImage(img)

            self.display.configure(image=tkImage)
            self.display.photo = tkImage
我也使用pygame来播放声音,但这会产生问题。由于我需要做大量的工作来显示每一帧,这意味着视频比音频慢,这会导致同步问题。是否有方法检测此同步问题并在迭代中跳过某些帧