Reputation: 81
I got "'utf-8' codec can't decode byte 0xb5 in position 1494: invalid start byte" when I try to access a local video file. I uploaded the file to google drive and ran the code in colab and it's fine. I got this problem when I ran it on local drive with jupyter notebook.
my code:
import moviepy.editor as mp
path='D:/Movie/Multimedia_Corpus/Test01/video_files/'
file='test01.rmvb'
fclip=mp.VideoFileClip(path+file)
error:
---------------------------------------------------------------------------
UnicodeDecodeError Traceback (most recent call last)
<ipython-input-23-1ebadda110d3> in <module>
9 for f in AllFiles:
10 print(f)
---> 11 fclip=mp.VideoFileClip(path+f,'rb')
~\anaconda3\lib\site-packages\moviepy\video\io\VideoFileClip.py in __init__(self, filename, has_mask, audio, audio_buffersize, target_resolution, resize_algorithm, audio_fps, audio_nbytes, verbose, fps_source)
86 # Make a reader
87 pix_fmt = "rgba" if has_mask else "rgb24"
---> 88 self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt,
89 target_resolution=target_resolution,
90 resize_algo=resize_algorithm,
~\anaconda3\lib\site-packages\moviepy\video\io\ffmpeg_reader.py in __init__(self, filename, print_infos, bufsize, pix_fmt, check_duration, target_resolution, resize_algo, fps_source)
33 self.filename = filename
34 self.proc = None
---> 35 infos = ffmpeg_parse_infos(filename, print_infos, check_duration,
36 fps_source)
37 self.fps = infos['video_fps']
~\anaconda3\lib\site-packages\moviepy\video\io\ffmpeg_reader.py in ffmpeg_parse_infos(filename, print_infos, check_duration, fps_source)
257 proc = sp.Popen(cmd, **popen_params)
258 (output, error) = proc.communicate()
--> 259 infos = error.decode('utf8')
260
261 del proc
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb5 in position 1494: invalid start byte
Upvotes: 1
Views: 2226
Reputation: 47
Try this:
infos = error.decode("utf-8", errors="ignore")
Or you can install moviepy==2.0.0.dev2
and it will work.
NB: The 2.0.0.dev2
version of moviepy
is not released yet.
Upvotes: 5
Reputation: 81
I found out that it's actually a bug of moviepy. I opened ffmpeg_reader.py and changed the line 259, i.e. the third error line posted in the question.
Original code:
infos = error.decode('utf8')
New code:
try:
infos = error.decode('utf8')
except:
infos = error.decode('ANSI')
Upvotes: 1