欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

询问 出现异常:OSError MoviePy error:Failed to read the first frame of the video file*.这可能意味着文件已损坏。

最编程 2024-06-28 18:43:13
...

我在做什么:

在一定时间内循环播放视频。

但是,我得到了以下错误(该文件没有损坏):

代码语言:javascript
复制
Exception has occurred: OSError
MoviePy error: failed to read the first frame of video file Pexels Videos 1292738.mp4. That might mean that the file is corrupted.

在我的代码中的注释行:

代码语言:javascript
复制
chdir(r'C:\Users\jack_l\Downloads\makeAVideo\stock')
myStock = next(walk(r'C:\Users\jack_l\Downloads\makeAVideo\stock'), (None, None, []))[2]
stockFile = VideoFileClip(str(myStock[0]), target_resolution=(1080, 1920), audio=False)
stockFile = stockFile.loop(duration = 300)
stockFile = stockFile.set_fps(30)
chdir(r'C:\Users\jack_l\Downloads\makeAVideo')
stockFile.write_videofile('theVideo.mp4') # this line

有人知道出了什么问题吗?任何帮助都是非常感谢的,谢谢。

我正在使用的文件:

https://drive.google.com/drive/folders/1n8ReLmPj8cIUi6og_GgmlRoumCMB7zIL?usp=sharing

全错误:

代码语言:javascript
复制
Traceback (most recent call last):
  File "c:\Users\jack_l\Downloads\makeVideos.py", line 40, in <module>
    stockFile.write_videofile('theVideo.mp4')
  File "<decorator-gen-55>", line 2, in write_videofile
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "<decorator-gen-54>", line 2, in write_videofile
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\decorators.py", line 135, in use_clip_fps_by_default
    return f(clip, *new_a, **new_kw)
  File "<decorator-gen-53>", line 2, in write_videofile
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\decorators.py", line 22, in convert_masks_to_RGB
    return f(clip, *a, **k)
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\video\VideoClip.py", line 300, 
in write_videofile
    ffmpeg_write_video(self, filename, fps, codec,
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\video\io\ffmpeg_writer.py", line 220, in ffmpeg_write_video
    for t,frame in clip.iter_frames(logger=logger, with_times=True,
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\Clip.py", line 472, in iter_frames
    frame = self.get_frame(t)
  File "<decorator-gen-11>", line 2, in get_frame
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\Clip.py", line 93, in get_frame    return self.make_frame(t)
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\Clip.py", line 136, in <lambda>    newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\Clip.py", line 187, in <lambda>    return self.fl(lambda gf, t: gf(t_func(t)), apply_to,
  File "<decorator-gen-11>", line 2, in get_frame
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\decorators.py", line 89, in wrapper
    return f(*new_a, **new_kw)
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\Clip.py", line 93, in get_frame    return self.make_frame(t)
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\video\io\VideoFileClip.py", line 113, in <lambda>
    self.make_frame = lambda t: self.reader.get_frame(t)
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 184, in get_frame
    result = self.read_frame()
  File "c:\users\jack_l\appdata\local\programs\python\python310\lib\site-packages\moviepy\video\io\ffmpeg_reader.py", line 133, in read_frame
    raise IOError(("MoviePy error: failed to read the first frame of "
OSError: MoviePy error: failed to read the first frame of video file Pexels Videos 1292738.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.