Created
August 22, 2021 03:26
-
-
Save FerdinaKusumah/d9a4aeb10b0bec1624108a27796b201c to your computer and use it in GitHub Desktop.
Python extract audio from mp4 video
This file contains hidden or 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
# Python code to convert video to audio | |
import moviepy.editor as mp | |
def convert_mp4_to_mp3(): | |
print("convert".center(20, "#")) | |
# Insert Local Video File Path | |
clip = mp.VideoFileClip("videoplayback.mp4") | |
# get duration file video in seconds | |
duration = clip.duration | |
print(duration) | |
# Insert Local Audio File Path | |
clip.audio.write_audiofile("audio.mp3") | |
print("done".center(20, "#")) | |
if __name__ == "__main__": | |
convert_mp4_to_mp3() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment