You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I encountered an AttributeError when attempting to write a video file using write_videofile in MoviePy. The error message indicates that a NoneType object has no attribute get_frame.
Full traceback:
AttributeError Traceback (most recent call last)
Cell In[8], line 1
----> 1 combined_vid.write_videofile("test.mp4")
File <decorator-gen-70>:2, in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, temp_audiofile_path, rewrite_audio, remove_temp, write_logfile, threads, ffmpeg_params, logger, pix_fmt)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:56, in requires_duration(f, clip, *a, **k)
54raiseValueError("Attribute 'duration' not set")
55else:
---> 56 return f(clip, *a, **k)
File <decorator-gen-69>:2, in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, temp_audiofile_path, rewrite_audio, remove_temp, write_logfile, threads, ffmpeg_params, logger, pix_fmt)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:135, in use_clip_fps_by_default(f, clip, *a, **k)
132 new_a = [fun(arg) if (name =="fps") else arg for (arg, name) inzip(a, names)]
133 new_kw = {k: fun(v) if k =="fps"else v for (k, v) in k.items()}
--> 135 return f(clip, *new_a, **new_kw)
File <decorator-gen-68>:2, in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, temp_audiofile_path, rewrite_audio, remove_temp, write_logfile, threads, ffmpeg_params, logger, pix_fmt)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:24, in convert_masks_to_RGB(f, clip, *a, **k)
22if clip.ismask:
23 clip = clip.to_RGB()
---> 24 return f(clip, *a, **k)
File <decorator-gen-67>:2, in write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, temp_audiofile_path, rewrite_audio, remove_temp, write_logfile, threads, ffmpeg_params, logger, pix_fmt)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:89, in preprocess_args.<locals>.wrapper(f, *a, **kw)
84 new_a = [
85 fun(arg) if (name in varnames) and (arg isnotNone) else arg
86for (arg, name) inzip(a, names)
87 ]
88 new_kw = {k: fun(v) if k in varnames else v for (k, v) in kw.items()}
---> 89 return f(*new_a, **new_kw)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\video\VideoClip.py:332, in VideoClip.write_videofile(self, filename, fps, codec, bitrate, audio, audio_fps, preset, audio_nbytes, audio_codec, audio_bitrate, audio_bufsize, temp_audiofile, temp_audiofile_path, rewrite_audio, remove_temp, write_logfile, threads, ffmpeg_params, logger, pix_fmt)
330 logger(message="Moviepy - Building video %s."% filename)
331if make_audio:
--> 332 self.audio.write_audiofile(
333 audiofile,
334 audio_fps,
335 audio_nbytes,
336 audio_bufsize,
337 audio_codec,
338 bitrate=audio_bitrate,
339 write_logfile=write_logfile,
340 logger=logger,
341 )
343 ffmpeg_write_video(
344self,
345 filename,
(...)
355 pix_fmt=pix_fmt,
356 )
358if remove_temp and make_audio:
File <decorator-gen-102>:2, in write_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, ffmpeg_params, write_logfile, logger)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:56, in requires_duration(f, clip, *a, **k)
54raiseValueError("Attribute 'duration' not set")
55else:
---> 56 return f(clip, *a, **k)
File <decorator-gen-101>:2, in write_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, ffmpeg_params, write_logfile, logger)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:89, in preprocess_args.<locals>.wrapper(f, *a, **kw)
84 new_a = [
85 fun(arg) if (name in varnames) and (arg isnotNone) else arg
86for (arg, name) inzip(a, names)
87 ]
88 new_kw = {k: fun(v) if k in varnames else v for (k, v) in kw.items()}
---> 89 return f(*new_a, **new_kw)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\AudioClip.py:230, in AudioClip.write_audiofile(self, filename, fps, nbytes, buffersize, codec, bitrate, ffmpeg_params, write_logfile, logger)
223exceptKeyError:
224raiseValueError(
225"MoviePy couldn't find the codec associated "226"with the filename. Provide the 'codec' "227"parameter in write_audiofile."228 )
--> 230 return ffmpeg_audiowrite(
231self,
232 filename,
233 fps,
234 nbytes,
235 buffersize,
236 codec=codec,
237 bitrate=bitrate,
238 write_logfile=write_logfile,
239 ffmpeg_params=ffmpeg_params,
240 logger=logger,
241 )
File <decorator-gen-97>:2, in ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize, codec, bitrate, write_logfile, ffmpeg_params, logger)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:56, in requires_duration(f, clip, *a, **k)
54raiseValueError("Attribute 'duration' not set")
55else:
---> 56 return f(clip, *a, **k)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\io\ffmpeg_audiowriter.py:204, in ffmpeg_audiowrite(clip, filename, fps, nbytes, buffersize, codec, bitrate, write_logfile, ffmpeg_params, logger)
192 logger(message="MoviePy - Writing audio in %s"% filename)
193 writer = FFMPEG_AudioWriter(
194 filename,
195 fps,
(...)
201 ffmpeg_params=ffmpeg_params,
202 )
--> 204 for chunk in clip.iter_chunks(
205 chunksize=buffersize, quantize=True, nbytes=nbytes, fps=fps, logger=logger
206 ):
207 writer.write_frames(chunk)
209 writer.close()
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\AudioClip.py:90, in AudioClip.iter_chunks(self, chunksize, chunk_duration, fps, quantize, nbytes, logger)
88assert size <= chunksize
89 tt = (1.0/ fps) * np.arange(pospos[i], pospos[i +1])
---> 90 yield self.to_soundarray(
91 tt, nbytes=nbytes, quantize=quantize, fps=fps, buffersize=chunksize
92 )
File <decorator-gen-99>:2, in to_soundarray(self, tt, fps, quantize, nbytes, buffersize)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:56, in requires_duration(f, clip, *a, **k)
54raiseValueError("Attribute 'duration' not set")
55else:
---> 56 return f(clip, *a, **k)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\AudioClip.py:138, in AudioClip.to_soundarray(self, tt, fps, quantize, nbytes, buffersize)
128"""129eliflen(tt)>1.5*buffersize:
130 nchunks =int(len(tt)/buffersize+1)
(...)
134for ttc in tt_chunks])
135"""136# print tt.max() - tt.min(), tt.min(), tt.max()
--> 138 snd_array = self.get_frame(tt)
140if quantize:
141 snd_array = np.maximum(-0.99, np.minimum(0.99, snd_array))
File <decorator-gen-28>:2, in get_frame(self, t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:89, in preprocess_args.<locals>.wrapper(f, *a, **kw)
84 new_a = [
85 fun(arg) if (name in varnames) and (arg isnotNone) else arg
86for (arg, name) inzip(a, names)
87 ]
88 new_kw = {k: fun(v) if k in varnames else v for (k, v) in kw.items()}
---> 89 return f(*new_a, **new_kw)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:98, in Clip.get_frame(self, t)
95return frame
96else:
97# print(t)
---> 98 return self.make_frame(t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\AudioClip.py:320, in CompositeAudioClip.__init__.<locals>.make_frame(t)
316defmake_frame(t):
318 played_parts = [c.is_playing(t) for c inself.clips]
--> 320 sounds = [
321 c.get_frame(t - c.start) * np.array([part]).T
322for c, part inzip(self.clips, played_parts)
323if (part isnotFalse)
324 ]
326ifisinstance(t, np.ndarray):
327 zero = np.zeros((len(t), self.nchannels))
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\AudioClip.py:321, in <listcomp>(.0)
316defmake_frame(t):
318 played_parts = [c.is_playing(t) for c inself.clips]
320 sounds = [
--> 321 c.get_frame(t - c.start) * np.array([part]).T
322for c, part inzip(self.clips, played_parts)
323if (part isnotFalse)
324 ]
326ifisinstance(t, np.ndarray):
327 zero = np.zeros((len(t), self.nchannels))
File <decorator-gen-28>:2, in get_frame(self, t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:89, in preprocess_args.<locals>.wrapper(f, *a, **kw)
84 new_a = [
85 fun(arg) if (name in varnames) and (arg isnotNone) else arg
86for (arg, name) inzip(a, names)
87 ]
88 new_kw = {k: fun(v) if k in varnames else v for (k, v) in kw.items()}
---> 89 return f(*new_a, **new_kw)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:98, in Clip.get_frame(self, t)
95return frame
96else:
97# print(t)
---> 98 return self.make_frame(t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:141, in Clip.fl.<locals>.<lambda>(t)
138 apply_to = []
140# mf = copy(self.make_frame)
--> 141 newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
143ifnot keep_duration:
144 newclip.duration =None
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:193, in Clip.fl_time.<locals>.<lambda>(gf, t)
189if apply_to isNone:
190 apply_to = []
192returnself.fl(
--> 193 lambda gf, t: gf(t_func(t)), apply_to, keep_duration=keep_duration
194 )
File <decorator-gen-28>:2, in get_frame(self, t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:89, in preprocess_args.<locals>.wrapper(f, *a, **kw)
84 new_a = [
85 fun(arg) if (name in varnames) and (arg isnotNone) else arg
86for (arg, name) inzip(a, names)
87 ]
88 new_kw = {k: fun(v) if k in varnames else v for (k, v) in kw.items()}
---> 89 return f(*new_a, **new_kw)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:98, in Clip.get_frame(self, t)
95return frame
96else:
97# print(t)
---> 98 return self.make_frame(t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:141, in Clip.fl.<locals>.<lambda>(t)
138 apply_to = []
140# mf = copy(self.make_frame)
--> 141 newclip = self.set_make_frame(lambda t: fun(self.get_frame, t))
143ifnot keep_duration:
144 newclip.duration =None
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:193, in Clip.fl_time.<locals>.<lambda>(gf, t)
189if apply_to isNone:
190 apply_to = []
192returnself.fl(
--> 193 lambda gf, t: gf(t_func(t)), apply_to, keep_duration=keep_duration
194 )
File <decorator-gen-28>:2, in get_frame(self, t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\decorators.py:89, in preprocess_args.<locals>.wrapper(f, *a, **kw)
84 new_a = [
85 fun(arg) if (name in varnames) and (arg isnotNone) else arg
86for (arg, name) inzip(a, names)
87 ]
88 new_kw = {k: fun(v) if k in varnames else v for (k, v) in kw.items()}
---> 89 return f(*new_a, **new_kw)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\Clip.py:98, in Clip.get_frame(self, t)
95return frame
96else:
97# print(t)
---> 98 return self.make_frame(t)
File c:\Users\user\miniconda3\envs\yt-dev\Lib\site-packages\moviepy\audio\io\AudioFileClip.py:88, in AudioFileClip.__init__.<locals>.<lambda>(t)
85self.buffersize =self.reader.buffersize
86self.filename = filename
---> 88 self.make_frame = lambda t: self.reader.get_frame(t)
89self.nchannels =self.reader.nchannels
AttributeError: 'NoneType' object has no attribute 'get_frame'
Expected Behavior
expected to write a mp4 file
Actual Behavior
attribute error
Steps to Reproduce the Problem
Specifications
Python Version: 3.11.9
MoviePy Version: 1.0.3
Platform Name: windows
Platform Version: 10
The text was updated successfully, but these errors were encountered:
Can you post your code so we can try and see where the problem might lie? It's a little hard to give a catchall answer, some more context would be good.
I encountered an AttributeError when attempting to write a video file using write_videofile in MoviePy. The error message indicates that a NoneType object has no attribute get_frame.
Full traceback:
Expected Behavior
expected to write a mp4 file
Actual Behavior
attribute error
Steps to Reproduce the Problem
Specifications
The text was updated successfully, but these errors were encountered: