How can I convert a mp4 or mpeg4 file to mp3 using python?
I have looked at several libraries without success.
How do you stop a mp3 in Python? Invoke the play() method on the object to play the song. To stop playing use stop() method on the object.
This works for many formats, such as WAV, FLAC, and OGG. However, MP3 is not supported.
This sounds like task for MoviePy. After you install it (installation howto) it could be used following way:
import os
from moviepy.editor import *
video = VideoFileClip(os.path.join("path","to","movie.mp4"))
video.audio.write_audiofile(os.path.join("path","to","movie_sound.mp3"))
Just replace "path","to","movie.mp4"
and "path","to","movie_sound.mp3"
according to your needs.
EDIT: To avoid the KeyError: 'video_fps', do ensure that you aren't inputting any video which does not contain any visual content.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With