MoviePy预览视频

电脑技术 电脑技术 1300 人阅读 | 0 人回复 | 2022-04-09

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

x
需要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)
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

热门推荐