Welcome folks today in this blog post we will be using the moviepy
library to convert the mp4 video to mp3 audio file in python. All the full source code of the application is shown below.
Get Started
In order to get started you need to install the below library moviepy
using the pip command as shown below
pip install moviepy
After this you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
from moviepy.editor import * mp4_file = "video.mp4" mp3_file = "audio.mp3" videoclip = VideoFileClip(mp4_file) audioclip = videoclip.audio audioclip.write_audiofile(mp3_file) audioclip.close() videoclip.close() |
As you can see we are importing the moviepy
library and then we are using the VideoFileClip
method inside that we are converting mp4 audio
to mp3 audio file.