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

AttributeError: AudioFileClip instance has no attribute 'afx' #513

Closed
batmanrising opened this issue Mar 27, 2017 · 8 comments
Closed

AttributeError: AudioFileClip instance has no attribute 'afx' #513

batmanrising opened this issue Mar 27, 2017 · 8 comments

Comments

@batmanrising
Copy link

batmanrising commented Mar 27, 2017

I was trying to experiment with audio but I am getting this error, where am I doing wrong ?

`from moviepy.editor import VideoFileClip, AudioFileClip, concatenate_videoclips
import moviepy.editor as mpe
import moviepy.audio.fx.all as afx

videoClip = VideoFileClip("testVideo.mp4")
audioClip = mpe.AudioFileClip("testAudio.mp3")

newAudio = (audioClip.afx( vfx.volumex, 0.5)
                     .afx( vfx.audio_fadein, 1.0)
                     .afx( vfx.audio_fadeout, 1.0))
new_clip = videoClip.set_audio(newAudio)

new_clip.write_videofile("newVidWithAudioFX.mp4")`
@Zulko
Copy link
Owner

Zulko commented Mar 27, 2017

please provide the error

@Zulko
Copy link
Owner

Zulko commented Mar 27, 2017

change audioClip.afx().afx()... to audioClip.fx().fx()

edit: since you are using moviepy editor you should be able to write:

newAudio = (audioClip.volumex(0.5)
                     .fadein(1.0)
                     .fadeout(1.0))

but you could also do all at once with:

new_clip = (videoClip
    .set_audio(newAudio)
    .volumex(0.5)
    .audio_fadein(1.0)
    .audio_fadeout(1.0)
)

edit 2: For such questions, which are not Moviepy bugs, please post rather on Stackoverflow or reddit/Moviepy.

@batmanrising
Copy link
Author

Before changing the code, the error was

Traceback (most recent call last):
File "tempVidAud1.py", line 10, in
newAudio = (audioClip.afx( vfx.volumex, 0.5)
AttributeError: AudioFileClip instance has no attribute 'afx'

And after changing it from audioClip.afx().afx()... to audioClip.fx().fx() the error is

Traceback (most recent call last):
File "tempVidAud1.py", line 10, in
newAudio = (audioClip.fx( vfx.volumex, 0.5)
NameError: name 'vfx' is not defined

@Zulko
Copy link
Owner

Zulko commented Mar 27, 2017

Add this:

from moviepy.editor import vfx

For such questions (which are more related to python than moviepy), refer to stackoverflow, or reddit/learnpython)

@tburrows13
Copy link
Collaborator

Should this be closed?

@ghost
Copy link

ghost commented Jun 14, 2017

closing since no response.

@ghost ghost closed this as completed Jun 14, 2017
@haishibei
Copy link

@Zulko
when i run the script as below :
newAudio = (audioClip.volumex(0.5) .fadein(1.0) .fadeout(1.0))
it report error below:
AttributeError: 'AudioFileClip' object has no attribute 'fadein

@Taitava
Copy link

Taitava commented Apr 17, 2021

@haishibei I was able to solve the same problem. Try to change newAudio = (audioClip.volumex(0.5) .fadein(1.0) .fadeout(1.0)) to newAudio = (audioClip.volumex(0.5) .audio_fadein(1.0) .audio_fadeout(1.0)). I have not used .volumex() so I don't know if that needs the audio_ prefix too or not.

This issue was closed.
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

5 participants