Sunday, 28 June 2020

Conversion of Video file(mp4) to an Audio file(mp3)

Some may have a thought about how to listen the audio without video, and also it is not the every individual aspect to listen the audio without seeing the video. Some have a thought about to listen the audio without a video.

The below code can help you in solving your problem.

Run this code using python3 in Your command prompt or any python IDE. Before that install python interpreter in your machine.

import os

try:
import moviepy
except ImportError:
print("Installing required modules")
os.system('python -m pip install moviepy')
print("successfully installed required modules")

import moviepy.editor as mp

try:
# Enter video file path in mp4 format
mp3=mp.VideoFileClip(r"Videofile.mp4")
except FileNotFoundError:
print("Enter the correct Video file path")
finally:
# Enter the audio file to create in mp3 format
mp3.audio.write_audiofile(r"audiofile.mp3")
print("Video file successfully converted to Audio file")

-> All the best, and continue for your success

No comments:

Post a Comment