Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NameError: global name 'clip' is not defined #114

Closed
tballas opened this issue Jan 17, 2015 · 3 comments
Closed

NameError: global name 'clip' is not defined #114

tballas opened this issue Jan 17, 2015 · 3 comments

Comments

@tballas
Copy link

tballas commented Jan 17, 2015

Hello,
First I want to say Moviepy is freaking magic! Thank you for making it!

Platform: Windows 7 64bit, Python 2.7.9

Issue:

Traceback (most recent call last):
  File "soccer_cuts.py", line 18, in <module>
    volumes = [volume(cut(i)) for i in range(0,int(clip.audio.duration-2))]
  File "soccer_cuts.py", line 16, in <lambda>
    cut = lambda i: clip.audio.subclip(i,i+1).to_soundarray(fps=22000)
  File "<string>", line 2, in to_soundarray
  File "C:\Python27\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python27\lib\site-packages\moviepy\audio\AudioClip.py", line 116, in to_soundarray
    tt = np.arange(0,clip.duration, 1.0/fps)
NameError: global name 'clip' is not defined

"clip" was not capitalized in line 116 of C:\Python27\lib\site-packages\moviepy\audio\AudioClip.py

I edited that to be consistent with the rest of the file: I changed:
from:

                tt = np.arange(0,clip.duration, 1.0/fps)

to:

                tt = np.arange(0,Clip.duration, 1.0/fps)

which gave this on the output:

Traceback (most recent call last):
  File "soccer_cuts.py", line 18, in <module>
    volumes = [volume(cut(i)) for i in range(0,int(inputvideoclip.audio.duration-2))]
  File "soccer_cuts.py", line 16, in <lambda>
    cut = lambda i: inputvideoclip.audio.subclip(i,i+1).to_soundarray(fps=22000)
  File "<string>", line 2, in to_soundarray
  File "C:\Python27\lib\site-packages\moviepy\decorators.py", line 54, in requires_duration
    return f(clip, *a, **k)
  File "C:\Python27\lib\site-packages\moviepy\audio\AudioClip.py", line 116, in to_soundarray
    tt = np.arange(0,Clip.duration, 1.0/fps)
AttributeError: class Clip has no attribute 'duration'

I looked at the C:\Python27\lib\site-packages\moviepy\audio\AudioClip.py file closer and I changed:
from:

                tt = np.arange(0,Clip.duration, 1.0/fps)

to:

                tt = np.arange(0,self.duration, 1.0/fps)

and It works now!

Did I mention that Moviepy is AMAZING? :)

@Zulko
Copy link
Owner

Zulko commented Jan 17, 2015

Thanks for the bug report and for the fix !

I can't believe this bug hadn't been reported yet. I'll correct that.

@tballas
Copy link
Author

tballas commented Jan 18, 2015

No problem. Glad to help!

@Zulko
Copy link
Owner

Zulko commented Jan 24, 2015

Fixed. Thanks for this !

@Zulko Zulko closed this as completed Jan 24, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants