How to convert VIDEO into audio using python

Rajat upadhyaya
1 min readMay 19, 2021

So today we will learn how we can convert video into audio file so for this we are going to use

Moivepy python library.

So here we will divide our code in two part

In the first part we will import all the packages

import moviepy.editor

from tkinter.filedialog import *

Here the in the first line we are going to import moviepy.editor for our main task changing video into audio , in second line we are using tkinter to take video files from our system.

So now we will go for the second step

select_video = askopenfilename()

videos = moviepy.editor.VideoFileClip(select_video)

caudio = videos.audio

audio.write_audiofile(“Demo.mp3”)

print(“completed”)

In the first line we are taking files from the system and in second line we are creating videos variable and passing selected video there, and in third line we are changing video into audio

Now our video is converted into audio file so in next line we will save that file.

So i hope you got every line very clearly.

--

--

Rajat upadhyaya

Application developer|Technical blogger|Youtuber(MASTERMIND CODER)|owner at www.yourtechnicalteacher.com