

{"id":108158,"date":"2022-03-12T09:00:04","date_gmt":"2022-03-12T03:30:04","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=108158"},"modified":"2026-06-01T14:07:43","modified_gmt":"2026-06-01T08:37:43","slug":"python-video-to-audio-converter","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/","title":{"rendered":"Python Video to Audio Converter Project"},"content":{"rendered":"<p>Video to audio converter is an application that allows you to convert your video to audio and video to mp3. In this application, you have to select a file and when you are done with selecting your video file just press the convert button. This video to audio converter application will then start converting video to audio and your audio file will be available in the same folder. Let&#8217;s develop Video to Audio Converter project using Python.<\/p>\n<h3>About Python Video to Audio Converter Project<\/h3>\n<p>The objective of the project is to convert a video into audio. In this project with the help of different libraries in python we\u2019ll convert a video(.mp file) into an audio(.mp3).<\/p>\n<h3>Project Prerequisites<\/h3>\n<p>To develop this project we need a basic knowledge of some models like tkinter, os, PIL and moviepy.<\/p>\n<p><strong>1. tkinter<\/strong> &#8211; for use Interface(UI)<\/p>\n<p><strong>2. os<\/strong> &#8211; provides functions for creating and removing a directory (folder), fetching its contents, changing and identifying the current directory, etc.<\/p>\n<p><strong>3. moviepy<\/strong> &#8211; MoviePy is a Python module for video editing, which can be used for basic operations (like cuts, concatenations, title insertions), video compositing (a.k.a. non-linear editing), video processing, or to create advanced effects.<\/p>\n<p><strong>4. PIL<\/strong> &#8211; Pillow is the friendly PIL fork by Alex Clark and Contributors. PIL is the Python Imaging Library by Fredrik Lundh and Contributors.<\/p>\n<h3>Download Video Audio Converter Source Code<\/h3>\n<p>Please download the full source code of Python video to audio converter: <a href=\"https:\/\/drive.google.com\/file\/d\/1aWvIXkFuGteWakFNxZbo23reZOQbSOnr\/view?usp=drive_link\"><strong>Video to Audio Converter Project Source Code<\/strong><\/a><\/p>\n<h3>Steps to Build Video to Audio Converter<\/h3>\n<ul>\n<li>Let\u2019s see the step to Build Video to Audio Converter<\/li>\n<li>First import all the necessary modules.<\/li>\n<li>Create a user interface window for our converter.<\/li>\n<li>After the user selects the file, create a function that will process the file and convert the video into audio.<\/li>\n<li>File will automatically get saved in the same folder.<\/li>\n<\/ul>\n<h3>Project File Structure<\/h3>\n<ol>\n<li>Importing modules<\/li>\n<li>Creating display function<\/li>\n<li>Defining Functions<\/li>\n<li>Calling main function<\/li>\n<\/ol>\n<h4>1. Importing Modules<\/h4>\n<p>We will first import all the necessary libraries required for this project.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># ==== Importing all the necessary libraries for Python Video to Audio Converter project\r\nfrom tkinter import *\r\nfrom tkinter import filedialog\r\nimport os\r\nfrom PIL import ImageTk\r\nimport moviepy.editor as mp\r\n<\/pre>\n<h4>2. Create Display Window<\/h4>\n<p>First, create a main class name as VideoAudioConverter, pass the root in an initiator function in which we will set the title, frames, background images and buttons for the interface.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># ==== creating main class\r\nclass VideoAudioConverter:\r\n   # ==== creating gui window\r\n   def __init__(self, root):\r\n       self.root = root\r\n       self.root.title(\"VIDEO-AUDIO CONVERTER by DataFlair\")\r\n       self.root.geometry('1280x720')\r\n       self.bg = ImageTk.PhotoImage(file=\"bg_image.jpg\")\r\n       Label(self.root, image=self.bg).place(x=0, y=0)\r\n\r\n       Button(self.root,text=\"Browse Files\",font=(\"times new roman\", 15),command=self.browse).place(x=40, y=630)\r\n<\/pre>\n<h4>3. Defining functions<\/h4>\n<p>In this part we\u2019ll discuss all the necessary functions which are required to complete our projects. We\u2019ll see the use of each function separately and how it\u2019ll work.<\/p>\n<p><strong>i. browse()<\/strong><\/p>\n<p>This function will browse the video files from the user and then process it using the convert function to convert the format of a file i.e., from .mp4 to .mp3.<\/p>\n<p>After converting the file it will show completed on the user interface.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># ==== browse data from system\r\n  def browse(self):\r\n      self.file_name = filedialog.askopenfilename(title=\"Select a File\", filetypes=((\"Video files\", \"*.mp4*\"),))\r\n\r\n      Label(self.root, text=os.path.basename(self.file_name), font=(\"times new roman\", 20), bg=\"blue\").place(x=200, y=630)\r\n\r\n      Label(self.root, text='Processing...', font=(\"times new roman\", 30)).place(x=600, y=630)\r\n      self.convert(os.path.basename(self.file_name))\r\n\r\n      Label(self.root, text='Completed!!', font=(\"times new roman\", 30)).place(x=1000, y=630)\r\n<\/pre>\n<p><strong>ii.<\/strong>\u00a0<strong>convert()<\/strong><\/p>\n<p>This function will take the path of a file as an input and with the help of the VideoFileClip function of moviepy library it will read the video file and with the audio.write_audiofile function it will convert the video file into an audio file.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># ==== convert video to audio\r\n def convert(self, path):\r\n     clip = mp.VideoFileClip(r'{}'.format(path))\r\n     clip.audio.write_audiofile(r'{}mp3'.format(path[:-3]))\r\n<\/pre>\n<h4>4. Creating main function<\/h4>\n<p>In the final step, we\u2019ll create a main function. In this function we declare the root and also create an object for our main class. Then we\u2019ll call this main function to execute our project.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\"># ==== creating main function of python Video to Audio Converter\r\ndef main():\r\n   # ==== create tkinter window\r\n   root = Tk()\r\n   # === creating object for class VideoAudioConverter\r\n   obj = VideoAudioConverter(root)\r\n   # ==== start the gui\r\n   root.mainloop()\r\n\r\nif __name__ == \"__main__\":\r\n   # ==== calling main function\r\n   main()\r\n<\/pre>\n<h3>Python Video to Audio Converter Project Output<\/h3>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter-output.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-108178\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter-output.webp\" alt=\"python video to audio converter output\" width=\"1920\" height=\"1017\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p><strong>YAY!!<\/strong> We have successfully developed the video to audio converter in python. We learn how to use tkinter to make GUI, os, moviepy, and PIL modules. Also we learned how to convert an .mp4 file to an .mp3 format. In order to make things easy, this tutorial is divided into various tasks.<\/p>\n<p>I hope you enjoyed building this project using this tutorial at <strong>DataFlair<\/strong>.!!<span hidden class=\"__iawmlf-post-loop-links\" data-iawmlf-links=\"[{&quot;id&quot;:2590,&quot;href&quot;:&quot;https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1aWvIXkFuGteWakFNxZbo23reZOQbSOnr\\\/view?usp=drive_link&quot;,&quot;archived_href&quot;:&quot;http:\\\/\\\/web-wp.archive.org\\\/web\\\/20260601083725\\\/https:\\\/\\\/drive.google.com\\\/file\\\/d\\\/1aWvIXkFuGteWakFNxZbo23reZOQbSOnr\\\/view?usp=drive_link&quot;,&quot;redirect_href&quot;:&quot;&quot;,&quot;checks&quot;:[{&quot;date&quot;:&quot;2026-06-02 03:58:38&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-08 09:10:53&quot;,&quot;http_code&quot;:200},{&quot;date&quot;:&quot;2026-06-16 18:35:12&quot;,&quot;http_code&quot;:200}],&quot;broken&quot;:false,&quot;last_checked&quot;:{&quot;date&quot;:&quot;2026-06-16 18:35:12&quot;,&quot;http_code&quot;:200},&quot;process&quot;:&quot;done&quot;}]\"><\/span><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Video to audio converter is an application that allows you to convert your video to audio and video to mp3. In this application, you have to select a file and when you are done&#46;&#46;&#46;<\/p>\n","protected":false},"author":5,"featured_media":108179,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[46],"tags":[21082,22734,26673,26672,26674],"class_list":["post-108158","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python-project","tag-python-project-for-beginners","tag-python-video-to-audio-converter","tag-python-video-to-audio-converter-project","tag-python-video-to-audio-converter-project-source-code"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Python Video to Audio Converter Project - DataFlair<\/title>\n<meta name=\"description\" content=\"Create Video to Audio Converter project using python modules like Tkinter for GUI. moviepy for video editing and PIL.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Python Video to Audio Converter Project - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Create Video to Audio Converter project using python modules like Tkinter for GUI. moviepy for video editing and PIL.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-03-12T03:30:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-06-01T08:37:43+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Python Video to Audio Converter Project - DataFlair","description":"Create Video to Audio Converter project using python modules like Tkinter for GUI. moviepy for video editing and PIL.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/","og_locale":"en_US","og_type":"article","og_title":"Python Video to Audio Converter Project - DataFlair","og_description":"Create Video to Audio Converter project using python modules like Tkinter for GUI. moviepy for video editing and PIL.","og_url":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-03-12T03:30:04+00:00","article_modified_time":"2026-06-01T08:37:43+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823"},"headline":"Python Video to Audio Converter Project","datePublished":"2022-03-12T03:30:04+00:00","dateModified":"2026-06-01T08:37:43+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/"},"wordCount":616,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter.webp","keywords":["Python project","python project for beginners","Python Video to Audio Converter","Python Video to Audio Converter project","Python Video to Audio Converter project source code"],"articleSection":["Python Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/","url":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/","name":"Python Video to Audio Converter Project - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter.webp","datePublished":"2022-03-12T03:30:04+00:00","dateModified":"2026-06-01T08:37:43+00:00","description":"Create Video to Audio Converter project using python modules like Tkinter for GUI. moviepy for video editing and PIL.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/03\/python-video-to-audio-converter.webp","width":1200,"height":628},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/python-video-to-audio-converter\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Python Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/python\/"},{"@type":"ListItem","position":3,"name":"Python Video to Audio Converter Project"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/7f83c342f5d1632d6f7b4b0b0f447823","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/4cf3a74600d131330b8c481d519afd1574093ed89f6d3396a95393ad223eb7cd?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team creates expert-level guides on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our goal is to empower learners with easy-to-understand content. Explore our resources for career growth and practical learning.","url":"https:\/\/data-flair.training\/blogs\/author\/dfteam1\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/108158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=108158"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/108158\/revisions"}],"predecessor-version":[{"id":148674,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/108158\/revisions\/148674"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/108179"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=108158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=108158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=108158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}