How to EXTRACT AUDIO from VIDEO using Python | Python Projects | GeeksforGeeks
Key Takeaways
Extracts audio from video using Python and MoviePy
Full Transcript
Hello everyone. My name is Shambhavi. Hope you all are doing well. So, in this particular video today, I'll be letting you know that how we can extract up the audio from any of the respective videos of any file format. You take it out MP3, you take it out MP4, you take .avi. Whatever the files you take it out, it's completely fine. First of all, onto the PyCharm, what I could do is that I could make up a new file. So, go on, click on new, go up here, Python file. Um Okay, so it will be um audio extractor. My file name, okay? Great. So, yeah. Here I am having up my respective file name. That's audio extractor, fine? Now, what I'm going to do up here is that I am going to start up importing up all of my respective libraries needed up here. Great. But, before that, let me give you an idea what sort of project this is going to be. Then I could move on forward. So, listen to me out. It will be a project into which you'll be entering up any of the respective video of your choice and of your format. Great. And from that respective file, then we will extract up the audio. It means that whatever the audio you are having up, we'll be extracting only that audio and we'll be saving that audio into our respective file format, whatsoever we want. Okay? That's the idea of the project which we are going to make up here today. So, what I would be needing for this project, I'll be needing up a video that shall contain some audio. Okay, I'll be needing up a video in that respective format which I'll have some audio also. So, what I am having up right away with me, uh this is my file and into this one, I'm having up this respective video from GeeksforGeeks itself. Okay, this one is one of the one which I'm having from GeeksforGeeks itself. So, I would use up this particular video only for converting that to that uh that particular format. Okay? So, this is what I'm going to do up here to extract up the audio from that. Right. What library will I be using? I'll be using up the moviepy. Moviepy, okay? Uh I would write that out here, moviepy like that. Okay, I'll be using up this particular library uh for my respective project. So, what's the process like? Do you need to install this or it doesn't need installation? So, yes, it needs up the installation. Command will be pip install moviepy. That same I'm going to go on to the terminal here and I'm going to write that down away. Okay? So, just let that terminal open up. Uh let me open this out as well. Mm great. So, it's pip install um moviepy. That's my respective one uh which um I really want to install it up here. Okay, I did out enter. Now, what is going to happen out? It will install up this particular library in a very short while. See, for me, the requirement is already satisfied. So, means it it means that I did have already downloaded that out. So, for me, it is showing that the requirement is already satisfied, but for you, if you haven't downloaded this up till now, so it will um show downloading. And after that, it will show completely full successfully downloaded in a short while. This is how it would uh go out for you, okay? So, um hope I'm pretty much clear with this particular thing that how it's going to be. So, I would close up this from here. Uh great. Now, what's my next task that I have to do? My next task is that I have to import that out. So, I'm going to write up import moviepy.editor. Now, what does this editor is actually here, but rather we uh didn't install that out. So, how actually we could write it up here? So, this editor is one sort of you can say it's a one sort of function that you have up in this moviepy library. What is it used for? It is used completely for editing up any respective video. Now, what are we going to do? We'll be extracting up audio from any respective video. What's that? That's the extracting. That's the editing which you are actually doing. So, yes, into that respective case, you will be needing up this respective editor one editor this particular uh function here so as to get your desired output. And that's the reason that I have simply put it up here like this editor, okay? That's simply the reason that why did I put this up. So, it is only the reason that I had done out, okay? Um great. Now, that's pretty much uh sorted. It's done. Now, what we're doing is that I'll be making up a variable uh that cvt_video. My variable name, okay? So, cvt_video, that's my variable name. And that I'm going to set it equal to moviepy. dot It will be uh editor dot, it will be video file clip. Okay. What is it that I already have right like written right away? So, see, listen to me out. This first of all, the CVT video is the respective variable which I had made it up here. Okay? Now, further to that, what starts moviepy.editor? That moviepy.editor is a same library and a similar function which I have imported up above. So, yes, I did wrote that out again here once, right? Further. Further, I have up a function that's video file clip function. What's that used for now? So, listen to me out. This video file clip function, it actually uh helps you to load up any particular video of any particular format. So, I'll be putting up my file name and it's this particular time to take here. This is my file name. Hit out enter. This is my respective file. Let me show you the name for that. Time to take your first estate to DSA GeeksforGeeks school live DSA classes. Now, the file format for this file is really very different, right? 3GPP. Let's say EXT uh EXT audio means extracting audio, okay? So, it's it's equal to CVT uh CVT underscore video dot, and I'm going to use up here the the one second, and like that, the audio function. This audio is one of the functions which you're having. What it does, it helps you to read and uh it helps you to actually uh read the audio which you are having up into that particular video. That's what this particular thing actually does out, okay? So, yeah, I am doing it the same Simply I did made up this variable as EXT_audio. That I did set up to CVT_video. What's that? CVT_video is a variable into which we have loaded our file from which we want to extract up the audio. Right? Further moving forward, I do have this audio function with me, right? That will help me to read up the audio. Let's get down. And here what I'm going to do is that I'm going to write up that EXT_audio, this respective variable, dot. I'm going to use up the write function, write_audio file. This will be my function which will help me to extract the audio from our video. This is my respective function which helps me to do so. So, into that particular case, I wrote write_audio file. Right? That's the particular thing which I did wrote it up here. And now further inside that, you will be writing up your that particular file name into which you want your audio to be extracted. And in whatever the format you want to want your file to be, that as well you could put it up. Right here, I was having up a 3GPP as my extension for my time to take here this particular file for my video. Now, I'll be extracting the audio into the MP3 format. Why I am doing up the things like that? Because I want to show you that the program which you we are writing up here, this respective project that we are making it up here, it's really capable of adding up these particular things to it this out. Right? That's the actual reason. Okay, nothing more than that. We can simply give it as um audio_extracted. .mp3. Like this I could give it up a file name, right? And yes, that's complete. Here I did audio sub this write audio file function. So this function allows me completely to write up the other audio to write up this respective um video into the audio format. It allows me to do so. And that's my reason that I did use up this write underscore audio file function here. That's my reason, actually. Okay? Now what I would do is that I would show you the file which we I would show you the video which we are going to convert it up here first of all, okay? So let me do that out very quickly. I'm going to go up here and I'm going to go up to Windows C. Then users. Um one second. Yes, and further I'm having up this user. I have PyCharm then I have GFG. Great. So where is that? Yeah, this is my particular file which I am having it up here, okay? So yeah, it it will open up in a short while. So this is a short one, okay? Okay. Uh great. So this is a sort of file which we are having and in that you have your respective video as well, right? I just wanted to show you that only thing that we are having up the video into this particular file like which we are actually having it up here. We have the video for that, right? Now what I would do is that I would run up my project here. Okay, let's run that out. It will take up some time. It It might take up some time for you that the length of your file it depends upon. See, in the file which I am having that's a very short file. Short file in the sense it's a it's somewhat of some seconds only. So it not it might not take more than one or two minutes for getting converted. But let's say your file your video which you're having that somewhat 20 minutes or half an hour. So, accordingly it will take that much time. But, yeah, at last it will convert that out for you. So, see, what do I got? I got that moviepy writing audio in audio_extracted.mp3. Done. It means that my file my audio has actually been extracted from this particular video. Okay? Now, let's go on to that destination here. And what was my file name? One second. Uh okay, it was audio extractor, okay. Let's get about it was A, right? Um yes, this is my file. Right, audio extracted. First of all, let me open up the properties for this, okay? So, I would go into the properties. Um let me take it up here. Okay, so yeah, that's an MP3 file. Right? And when it is it is created created somewhat at same time, right? Um I have some one thing to show you. Actually, I haven't increased up the voice. So, just do out one simple thing. Listen to some starting four to five words whatever it is in the video so that we can start it out the audio which has been extracted is that correct or not, okay? Just listen this out. Hello everyone. Welcome to Sudiks. So, I'm here with a new announcement for all the students who Okay. So, yeah, I know that you must have listened out the very starting few words which are there. Now, I'm going to go on to my audio_extracted. First of all, see the difference. First of all, just see out the difference here. This file which I am having, this is automatically having up some video format. It's automatically having that out. Let me show you. One second. Yeah, have a look over here. This respective file which is it is automatically having up a video format into it because this is how a video looks like, right? See, this is one of the videos, so it is also looking at the same. This is one another video, so it is also having the same look. But, now if I take you to above, if I take you to above right away, how is it going to look? See here, it is automatically looking that some or the other audio file we are having it up here. Right, now let me run that out and let's listen that out what's actually here. So, I'm going to open it out, okay? Hello everyone, welcome to GeeksforGeeks. I'm here with a new announcement for all the students who are in class 9th to class 12. Okay, so this was similar, right? I I showed you the video from which we are extracting. Even I showed you the audio which has been extracted. I showed you both the things, right? Now, the content is absolutely similar here, right? No difference. It's not that case that the video is something other and the extracted audio is something other, right? So, into that particular case, I hope that you did got up an idea about this conversion. So, I hope this project is pretty much clear to you that how you can make up this particular project and use that accordingly, right? So, this is all for this video. Till then, thank you and take care.
Original Description
🔊 Uncover the secrets of audio extraction from videos in our latest Python tutorial! In this step-by-step guide, we'll guide you through the process of extracting audio from a video using Python and the MoviePy library.
We will walk you through the step-by-step process of utilizing the MoviePy library to seamlessly extract audio from video files. Learn how to navigate the world of multimedia programming, harness the capabilities of MoviePy, and master the art of extracting audio with precision and ease.
📑 Relate Article: https://www.geeksforgeeks.org/video-to-audio-convert-using-python/
-------------------------------------------------------------------------
📈 Want to learn more about Data Science?
Check out our Data Science Course: https://www.geeksforgeeks.org/courses/full-stack-applied-data-science-program?utm_source=youtube&utm_medium=main_channel&utm_campaign=python_projects
📚 Explore Our Courses: https://practice.geeksforgeeks.org/courses?utm_source=youtube&utm_medium=main_channel&utm_campaign=python_projects
-------------------------------------------------------------------------
Follow us for more fun, knowledge, and resources:
💬 Twitter- https://twitter.com/geeksforgeeks
🧑💼 LinkedIn- https://www.linkedin.com/company/geeksforgeeks
📷 Instagram- https://www.instagram.com/geeks_for_geeks/?hl=en
💌 Telegram- https://t.me/s/geeksforgeeks_official
📱 Download GeeksforGeeks' Official App: https://geeksforgeeksapp.page.link/gfg-app
#GeeksforGeeks #GfG #pythonprojects #python #audioextractor #extractaudio #audio #moviepy #audiofromvideo
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from GeeksforGeeks · GeeksforGeeks · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
How I got into Walmart | Shailesh Sharma
GeeksforGeeks
Upgrade yourself In 29 Days | GeeksforGeeks
GeeksforGeeks
Learn AWS Fundamentals For Free
GeeksforGeeks
Conversation With Young Achievers | Meet the winners of Bi-Wizard Coding Contest | GeeksforGeeks
GeeksforGeeks
Meet The Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
Interview Prep Strategies | PayPal
GeeksforGeeks
OLX Interview Preparation Strategies | Hukam Singh
GeeksforGeeks
Meet Some More Winners Of Bi-Wizard Coding Contests | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Microsoft Azure For Absolute Beginners
GeeksforGeeks
Python for Data Science | Data Science Master Bootcamp | Arpit Jain
GeeksforGeeks
Getting Started with Data Analysis | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
How to prepare theory subjects for SDE interviews | Geeks Summer Carnival 2022
GeeksforGeeks
Get Your Tickets To The Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
TED Talk Data Analysis Project | Data Science Master Bootcamp | Ashish Jangra
GeeksforGeeks
How I Secured AIR 9 in GATE'22 | Tushar
GeeksforGeeks
Learn Java Backend Development | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
How to Recognize which Data Structure to use in a question | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
Learn Data Structures and Algorithms | GeeksforGeeks
GeeksforGeeks
Interview experience at Flipkart | GeeksforGeeks
GeeksforGeeks
Lets Prepare for GATE'23 the Right Way | Sakshi Singhal | GeekSummerCarnival
GeeksforGeeks
Highest Paying Jobs in 2022 | Ishan Sharma | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival 2022 | 5th April- 11th April | GeeksforGeeks
GeeksforGeeks
Preparing for SDE interviews | Soham Mukherjee | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Full Stack Development with React & Node | Utkarsh Malik | Geeks Summer Carnival | GeeksforGeeks
GeeksforGeeks
Introduction to Open Source and Roadmap to GSOC 2022 | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Web Scraping in Action | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Getting Hired at BITCS via GfG Job Portal | Get Hired With GeeksforGeeks
GeeksforGeeks
How to build a faster landing Page | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival | 5th To 11th April, 2022 | GeeksforGeeks
GeeksforGeeks
How to get ideas for Startup | Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Journey from Tier 3 to JusPay | GeeksforGeeks
GeeksforGeeks
Geeks Summer Carnival 2022 | GeeksforGeeks
GeeksforGeeks
Dispelling Myths and Pre conceptions of Programming Languages
GeeksforGeeks
Must Do System Design Questions
GeeksforGeeks
Understanding Sorting Techniques in an hour | Keerti Purswani | Geeks Summer Carnival
GeeksforGeeks
Get Hired at NEC | Job-A-Thon 8
GeeksforGeeks
Journey from Tier 3 college to Microsoft | GeeksforGeeks
GeeksforGeeks
Get Hired with GeeksforGeeks at SuperK | Job A Thon 8
GeeksforGeeks
GeeksforGeeks: Redesigned
GeeksforGeeks
From Tier 3 to cracking multiple interviews | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Youtube Data Analysis | Ashish Jangra | GeeksforGeeks
GeeksforGeeks
DSA Self-Paced Course Preview | Sandeep Jain | GeeksforGeeks
GeeksforGeeks
GATE Live Classes | Prepare for GATE CS 2023 | GeeksforGeeks
GeeksforGeeks
Journey from JIIT to Adobe
GeeksforGeeks
Life Is Unfair Ft. Shonty badmash | LIVE Discord Session | A GeeksforGeeks Exclusive
GeeksforGeeks
Interview Experience at Google | Tech Dose
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Interview Experience @ Amazon | GeeksforGeeks
GeeksforGeeks
My journey through the tech world from India to US | Vidushi | GeeksforGeeks
GeeksforGeeks
Complete Interview Preparation Course | GeeksforGeeks
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Getting Hired at FiftyFive Technologies | Job-a-thon 9.0
GeeksforGeeks
GFG Karlo, Ho Jayega | GeeksforGeeks ft. Khaleel Ahmed
GeeksforGeeks
How I got job offers from 2 big companies : Arcesium & Microsoft | GeeksforGeeks
GeeksforGeeks
LINUX for Beginners | GFG x Itversity
GeeksforGeeks
My interview experience at Walmart | GeeksforGeeks
GeeksforGeeks
Get Hired at Speckyfox
GeeksforGeeks
Live Mock DSA
GeeksforGeeks
Related Reads
📰
📰
📰
📰
How to build a faceless YouTube channel with AI in 30 days
Dev.to AI
What Is Cognitive Training? A Beginner's Guide for Adults
Dev.to AI
Bukan Menggantikan, Ini Cara Memanfaatkan AI Terkini untuk Naikin Produktivitas Kerjamu
Medium · AI
Rytr vs QuillBot for Academic Writing 2026: Which AI Tool Actually Saves Your Thesis?
Dev.to AI
🎓
Tutor Explanation
DeepCamp AI