Convert MP4 To MP3 Using Python

Shweta Lodha
1 min readSep 19, 2022

If you are struggling to find a free tool to convert your mp4 to mp3, then this is the right article for you.

Image by Pete Linforth at Pixabay

This article would be very short as converting mp4 to mp3 is just 3 lines of code:)

Let’s start the magic.

Required Package

In order to perform this conversion, one needs to install a Python package named moviepy and it can be done using the following pip command:

pip install moviepy

Code To Convert MP4 To MP3

Once the required package is installed, it is just a matter of writing few lines of code:

import moviepy.editor as edvideo = ed.VideoFileClip(‘test.mp4’)video.audio.write_audiofile(‘test.mp3’)

Hope you enjoyed writing such a useful utility. Make sure to check out my video demonstrating the same:

--

--

Shweta Lodha
Shweta Lodha

No responses yet