获取视频剪辑的最后一帧,并使用moviepy扩展10个片段

时间:2019-12-15 07:17:16

标签: python moviepy

我正在使用moviepy编辑一些视频片段。我想播放原始剪辑的最后一帧10秒钟,以便可以在上面显示一些文本。我尝试使用

将最后一帧转换为视频
clip.to_ImageClip(t=clip.duration).set_duration(10)

但是失败了。

有人知道为什么吗?以及任何可能的解决方案。

import moviepy.editor as ed
import os

content=ed.VideoFileClip(path)
myclip=content.to_ImageClip(content.duration).set_duration(10)
myclip.write_videofile(path)

MoviePy错误:

failed to read the first frame of video file C:\my\test.mp4. 

That might mean that the file is corrupted. 
That may also mean that you are using a deprecated version of FFMPEG. 
On Ubuntu/Debian for instance the version in the repos is deprecated. 
Please update to a recent version from the website. 

1 个答案:

答案 0 :(得分:0)

我也面临同样的问题,但是,下面的代码对我有用:

clip = VideoFileClip(path)
frame_t = clip.duration - 1
ext_clip = clip.to_ImageClip(t=frame_t, duration=4)
ext_clip.write_videofile("sample4.mp4", fps=24)