"KeyError: 'video_fps'" when trying to convert youtube webm to mp3
See original GitHub issueI’m downloading audio in mp4/web containers using Pytube, but I’m getting “KeyError: ‘video_fps’” when trying to convert them to mp3 with moviepy.
Code:
import moviepy.editor as mp
from pytube import YouTube
#download video
youtubeurl = "https://www.youtube.com/watch?v=jYypQueS3ew&index=3&list=PL1nNuwHORUCPajRTocTSCJheaMzbWRu23&t=0s"
yt = YouTube(youtubeurl)
stream = yt.streams.filter(subtype='webm',only_audio=True).last().download("/home/jaws/Desktop/Stuff/Moosepy/temp/", filename="temp_audio")
print stream
print "Done!"
#convert to mp3
clip = mp.VideoFileClip("/home/jaws/Desktop/Stuff/Moosepy/temp/temp_audio.webm").subclip()
clip.audio.write_audiofile("audio.mp3")
print "Done!"
Output:
Traceback (most recent call last): File “/home/jaws/Desktop/Stuff/Moosepy/test.py”, line 13, in <module> clip = mp.VideoFileClip(“/home/jaws/Desktop/Stuff/Moosepy/temp/temp_audio.webm”).subclip() File “/home/jaws/.local/lib/python2.7/site-packages/moviepy/video/io/VideoFileClip.py”, line 91, in init fps_source=fps_source) File “/home/jaws/.local/lib/python2.7/site-packages/moviepy/video/io/ffmpeg_reader.py”, line 34, in init self.fps = infos[‘video_fps’] KeyError: ‘video_fps’
Am I missing the codec? It converts mp4 and Webm video files to mp3 fine. It’s just these weird audio files in webm/mp4 containers that won’t convert. I guess since the FPS is 0, that’s throwing up the error? How can I get around this? ` Moviepy 0.2.3.5 Python 2.7.12
Issue Analytics
- State:
- Created 5 years ago
- Comments:12

Top Related StackOverflow Question
I got this problem when trying to do this for my personal mp3 yt downloader. I got the solution. Instead of using
VideoFileClipand itsVideoFileClip.audio, just useAudioFileClip. This worked for me. If you have trouble with this, use the full path instead of the relative path shown here.some videos doesn`t have visual content but have audio,how can I get the audio with mp3