Reputation: 31
import moviepy.editor
# Replace the parameter with the location of the video
video = moviepy.editor.VideoFileClip("/home/amit/video2.mp4")
audio = video.audio
# Replace the parameter with the location along with filename
audio.write_audiofile("/home/amit/output.mp3")
This is the code and getting this error:
AttributeError: 'NoneType' object has no attribute 'write_audiofile'
Upvotes: 2
Views: 4537
Reputation: 527
It appears that the value of video.audio is None, which is python's null value.
Null values do not have any attributes, so you are getting an AttributeError when attempting to access an attribute that doesn't exist.
In this specific case, this may mean that moviepy was not able to find audio in video2.mp4.
You may be able to get more info by calling the following:
print(video.reader.infos)
Upvotes: 2