I am trying to extract and save a frame from an .mp4 using moviepy like so (simplified):
from moviepy.editor import *
clip = VideoFileClip('conditiontest1.mpg')
clip.save_frame('frame1.png', 20)
When I run this I get:
Traceback (most recent call last):
File"C:\Users\boss\Documents\DVDFab\Video Enhancer AI\join.py", line 23, > in clip = VideoFileClip(d + f + '.mp4') ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\moviepy\video\io\VideoFileClip.py", > line 88, in init_ self.reader = FFMPEG_VideoReader(filename, pix_fmt=pix_fmt, ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\moviepy\video\io\ffmpeg_reader.py", > line 73, in init_ self.lastread = self.read_frame() ^^^^^^^^^^^^^^^^^
File "C:\Python311\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 > conditiontest1.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.
Quite a few people have reported this error. The file is not corrupted, at least it plays fine in VLC. I have the latest FFMPEG. I have tried the other recommended fix, i.e. giving the full path. No help.
One interesting thing is that this only seems to happen to me when I'm processing clips I've produced with moviepy, as in:
from moviepy.editor import *
clip = VideoFileClip('conditiontest.mpg4')
clip1 = clip.subclip(10,60)
clip1.write_videofile('conditiontest1.mpg4',codec='libx264')
That runs fine. Anyone have ideas how I can fix this?