Created
July 25, 2020 12:07
-
-
Save sshopov/b5adb81b8e6632aa4133b9115527de4a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
Takes a folder and converts all .mp4 files in it to .mp3. | |
It saves the mp3 files to the same directory using the original name but with an .mp3 extension. | |
Based on: | |
https://www.tutorialexample.com/a-complete-guide-to-python-convert-mp4-to-mp3-with-moviepy-python-tutorial/ | |
Pre-requisites: | |
Python 3.7 | |
pip install moviepy | |
''' | |
import glob | |
import os | |
from moviepy.editor import * | |
folder = r'E:' | |
for mp4 in glob.glob(os.path.join(folder, '*.mp4')): | |
mp3 = mp4.replace('.mp4', '.mp3') | |
videoclip = VideoFileClip(mp4) | |
audioclip = videoclip.audio | |
audioclip.write_audiofile(mp3) | |
audioclip.close() | |
videoclip.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment