willsonlincake 发表于 2022-4-9 00:39:07

MoviePy预览视频

需要PyGame
You must execute VideoFileClip before previewing.

The method askopenfile selects a file.
Execute clip = VideoFileClip(file.name) for creating VideoFileClip object.
Then you can execute clip.without_audio().preview().

For more details see: MoviePy – Previewing a Video Clip.

When executing the code, I was getting an error message:

clip.preview requires Pygame installed

I has to install pygame.

Here is a code sample for selecting and previewing a video file:

from tkinter.filedialog import askopenfile
from moviepy.editor import *
   
file = askopenfile(initialdir = ".", title="choose a video", filetype=[("Video Files","*.mp4")])

if file:
    print("File was loaded")

    # https://www.geeksforgeeks.org/moviepy-previewing-a-video-clip/
    # Loading video file
    clip = VideoFileClip(file.name)
   
    # previewing the clip at fps = 10
    clip.without_audio().preview(fps=10)
页: [1]
查看完整版本: MoviePy预览视频