question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ImageClip methods- NameError: name 'func' is not defined

See original GitHub issue

NameError 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:closed
  • Created a year ago
  • Reactions:1
  • Comments:7

github_iconTop GitHub Comments

3reactions
furascommented, May 6, 2022

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 put f in place of func

python - NameError within moviepy subclip function - Stack Overflow

0reactions
Tengloncommented, May 25, 2022

same problem, when trying to extract the audio from video.

to reproduce:

import moviepy.editor as mp
my_clip = mp.VideoFileClip(r"test.mp4")
my_clip.audio.write_audiofile(r"test.mp3")

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

NameError: name 'func' is not defined - python - Stack Overflow
Does anyone see why I'm getting a "func undefined" error here? Everything looks correct to me.
Read more >
Classes of Video Clips — MoviePy 1.0.2 documentation
General processing of a clip. Returns a new Clip whose frames are a transformation (through function fun ) of the frames of the...
Read more >
How to use the moviepy.editor.VideoFileClip function in ... - Snyk
To help you get started, we've selected a few moviepy.editor.VideoFileClip examples, based on popular ways it is used in public projects.
Read more >
Working with skimage – Image Processing with Python
docx , the file is not saved as a PDF document. Named versus positional arguments. When we call functions in Python, there are...
Read more >
Source code for moviepy.video.VideoClip
If mask is ``None``, The video clip is fully opaque. audio (default None) An AudioClip instance containing the audio of the video clip....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found