moviepy用VideoFileClip加载视频时报UnicodeDecodeError: utf-8 codec cant decode byte invalid start byte错误

使用moviepy用:
clip1 = VideoFileClip('F:\\video\\3.mp4')加载视频时报错,如下:

Traceback (most recent call last):
File “<pyshell#3>”, line 1, in
clip1 = VideoFileClip(‘F:\video\3.mp4’)
File “C:\Program Files\Python37\lib\site-packages\moviepy\video\io\VideoFileClip.py”, line 91, in init
fps_source=fps_source)
File “C:\Program Files\Python37\lib\site-packages\moviepy\video\io\ffmpeg_reader.py”, line 36, in init
fps_source)
File “C:\Program Files\Python37\lib\site-packages\moviepy\video\io\ffmpeg_reader.py”, line 259, in ffmpeg_parse_infos
infos = error.decode(‘utf8’)
UnicodeDecodeError: ‘utf-8’ codec can’t decode byte 0xb9 in position 1721: invalid start byte

这种情况只在少数视频文件处理时报错,应该是解码问题,打开moviepy\video\io\ffmpeg_reader.py文件,将该行代码:
infos = error.decode(‘utf8’)
改为:infos = error.decode(‘ANSI’)
重启解释器后再执行问题顺利解决。

跟老猿学Python、学5G!

posted @ 2020-05-11 20:14  老猿学Python  阅读(761)  评论(0编辑  收藏  举报