python使用MoviePy 视频合并报错:OSError: MoviePy error: failed to read the first frame of video file xxx的解决方法
!公众号:笔记分享社。
·
已解决:OSError: MoviePy error: failed to read the first frame of video file \\视频\ts\78.ts. 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.
报错信息翻译:OSError: MoviePy error:无法读取视频文件的第一帧 xxx.mp4.这可能意味着文件已损坏。这也可能意味着您使用的是已弃用的 FFMPEG 版本。例如,在 Ubuntu/Debian 上,存储库中的版本已被弃用。请从网站更新到最新版本。
因为在做视频合并的时候老是报这个错误,又要重新运行脚本,很烦,为了解决该问题尝试了很多方法,最后在GitHub上找到了类似情况话题,找到了解决方法:在moviepy库下找到.../moviepy/video/io/ffmpeg_reader.py该文件,找到close()函数,把最后两行注释掉,成功解决。如下:
# if hasattr(self, 'lastread'):
# del self.lastread
def close(self):
if self.proc:
self.proc.terminate()
self.proc.stdout.close()
self.proc.stderr.close()
self.proc.wait()
self.proc = None
# if hasattr(self, 'lastread'):
# del self.lastread
来源GitHub:该回答显示时间在2020年2月,在社区里讨论最多的是关于MoviePy包内部逻辑的问题,我是用pip命令下载的MoviePy库 版本号为1.0.3。
附上GitHub话题地址:https://github.com/Zulko/moviepy/issues/1078
在该板块下寻找到了更好的解决办法,最后找到了.../moviepy/video/io/ffmpeg_reader.py的迭代版本,替换原来的ffmpeg_reader.py后运行,也成功解决了该问题。
附上迭代版本源地址:https://github.com/tburrows13/moviepy/blob/617ee91f8aa05e12127a1f18e7260bc0b8a4f2e2/moviepy/video/io/ffmpeg_reader.py
以上是此问题报错原因的解决方法,欢迎评论区留言讨论是否能解决,如果有用欢迎点赞收藏文章谢谢支持!!!
公众号:笔记分享社
更多推荐
已为社区贡献1条内容
所有评论(0)