ImageClip methods- NameError: name 'func' is not defined
See original GitHub issueNameError found for multiple moviepy functions while trying to resize an imageClip. I tested creating ImageClips different ways, from setting duration inside the ImageClip fxn (worked) and also using moviepy.video.fx.resize function. I read the source code and discovered a work around to resizing the image clip by:
1.) converting the .png to PIL.Image.Image,
2.) resizing using PIL methods [ Image.open()
] ,
3.) converting to a numpy array [ np.array()
],
4.) and finally converting into ImageClip
However, the same NameError also appears when I go to create a CompositeVideoClip.
Following other user experiences, I ensured all dependencies are up-to-date, and also restarted my computer.
Expected Behavior
set size and duration of ImageClip in one line. Create a CompositeVideoClip which will be concatenated with other VideoFileClips later on.
Actual Behavior
Traceback (most recent call last):
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\multiprocessing\process.py", line 315, in _bootstrap
self.run()
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\multiprocessing\process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "C:\Users\rloiselle\gitProjects\auv\GobyBot\unpack\unpackBagFunctions.py", line 869, in AUV_bag_unpack_video_charts
add_USGS_reqs(videoName,videoName2)
File "C:\Users\rloiselle\gitProjects\auv\GobyBot\video\videoFunctions.py", line 394, in add_USGS_reqs
USGS_logo = ImageClip(clipNm).set_duration(dur).resize(size)
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\site-packages\moviepy\decorators.py", line 29, in apply_to_mask
newclip = f(clip, *a, **k)
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\site-packages\moviepy\decorators.py", line 41, in apply_to_audio
newclip = f(clip, *a, **k)
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\site-packages\decorator.py", line 232, in fun
return caller(func, *(extras + args), **kw)
File "C:\Users\rloiselle\Anaconda3\envs\ros_env\lib\site-packages\moviepy\decorators.py", line 79, in wrapper
names = inspect.getfullargspec(func).args
NameError: name 'func' is not defined
Steps to Reproduce the Problem
from moviepy import *
video_file= "path_to_video.mp4"
video = VideoFileClip(video_file)
dur = video.duration
size = video.size
clipNm = "path_to_watermark.png"
USGS_logo = ImageClip(clipNm).set_duration(dur).resize(size)
video_watermarked = CompositeVideoClip([video, USGS_logo])
Specifications
- Python Version: 3.8.12
- Moviepy Version: 1.0.3
- Platform Name: Windows 10 Enterprise
- Platform Version: 21H2 build 19044.1645
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7
I can’t reproduce this problem with MoviePy 1.0.3 on Linux without Anaconda. And I don’t see this problem in current code on GitHub. Maybe it is problem only with version installed with Anaconda.
But someone on Stackvoflow had the same problem and (s)he opened
decorators.py
and putf
in place offunc
python - NameError within moviepy subclip function - Stack Overflow
same problem, when trying to extract the audio from video.
to reproduce:
Error located in decorate.py as well
NameError Traceback (most recent call last) Input In [6], in <cell line: 2>() 1 my_clip = mp.VideoFileClip(r"/home/longteng/datasets/act-net/v_-_gDSRlC1kg.mp4") ----> 2 my_clip.audio.write_audiofile(r"test.mp3")
File ~/anaconda3/envs/ptc/lib/python3.9/site-packages/decorator.py:232, in decorate.<locals>.fun(*args, **kw) 230 if not kwsyntax: 231 args, kw = fix(args, kw, sig) –> 232 return caller(func, *(extras + args), **kw)
File ~/anaconda3/envs/ptc/lib/python3.9/site-packages/moviepy/decorators.py:54, in requires_duration(f, clip, *a, **k) 52 raise ValueError(“Attribute ‘duration’ not set”) 53 else: —> 54 return f(clip, *a, **k)
I am using version 1.0.3