gpt4 book ai didi

python - 获取视频剪辑的最后一帧并使用 moviepy 延长 10 秒

转载 作者:行者123 更新时间:2023-12-05 08:06:42 42 4
gpt4 key购买 nike

我正在使用 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.

最佳答案

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

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)

关于python - 获取视频剪辑的最后一帧并使用 moviepy 延长 10 秒,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59341931/

42 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com