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.

"KeyError: 'video_fps'" when trying to convert youtube webm to mp3

See original GitHub issue

I’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:open
  • Created 5 years ago
  • Comments:12

github_iconTop GitHub Comments

22reactions
sh0tzzcommented, Aug 1, 2020

I got this problem when trying to do this for my personal mp3 yt downloader. I got the solution. Instead of using VideoFileClip and its VideoFileClip.audio, just use AudioFileClip. This worked for me. If you have trouble with this, use the full path instead of the relative path shown here.

# mp4 to mp3
clip = AudioFileClip('testfile.mp4')
clip.write_audiofile('testfile.mp3')
clip.close()
1reaction
2879786424commented, Sep 1, 2020

The error occurs when the video doesn’t contain any visual content, ensure you are uploading a video which is not blank.

some videos doesn`t have visual content but have audio,how can I get the audio with mp3

Read more comments on GitHub >

github_iconTop Results From Across the Web

KeyError: 'video_fps' with moviepy ffmpeg - Stack Overflow
After removing the only_audio=True input, a normal video was downloaded and then the conversion happened as it should have.
Read more >
How to Convert WebM to MP4 in Seconds [Beginner's Tutorial]
Best WebM to MP4 Converter: https://www.winxdvd.com/hd-video-converter-deluxe/?ttref=ytboffi-vcd-2102032Find your WebM videos not playing on ...
Read more >
Convert webm to mp3 using VLC - YouTube
How to convert webm to mp3 using VLC.Checkout - https://www.cpclips.com.
Read more >
How to Convert WebM to MP4 | Free with HandBrake - YouTube
Are you looking for a WebM converter to convert your video files from WebM to MP4? In this tutorial, I will show you...
Read more >
Convert Webm to mp3 (extract audio) #ffmpeg - YouTube
Code issue: Convert Webm to mp3 (extract audio)Technology: ffmpegSource: https://onelinerhub.com/ffmpeg/ convert - webm-to-mp3 -extract-audio.
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