44
loading...
This website collects cookies to deliver better user experience
I didn't not add error handling code
pip install moviepy
import tkinter as tk
from tkinter.filedialog import askopenfile
from tkinter.messagebox import showinfo
from moviepy.editor import VideoFileClip
class Converter(tk.Tk):
def __init__(self):
super().__init__()
self.geometry("500x250")
convert_label = tk.Label(self, text="Convert to mp3:", font="lucida 40")
convert_label.pack()
select_mp3 = tk.Button(self, text="Select", font="lucida 15", command=self.convert_to_mp3)
select_mp3.pack()
def convert_to_mp3(self):
file = askopenfile(mode="r", filetypes=[('mp4 file', '*.mp4')])
mp4_file = file.name
mp3_file = mp4_file.replace("mp4", "mp3")
video = VideoFileClip(mp4_file)
audio = video.audio
audio.write_audiofile(mp3_file)
audio.close()
video.close()
showinfo(title="Done", message="Your mp4 file has been converted to mp3\nCheck your directory")
convert = Converter()
convert.mainloop()
print("Importing...")
import tkinter as tk
from tkinter.filedialog import askopenfile
from tkinter.messagebox import showinfo
from moviepy.editor import VideoFileClip
print("Working...")
class Converter(tk.Tk):
def __init__(self):
super().__init__()
self.geometry("500x250")
convert_label = tk.Label(self, text="Convert to mp3:", font="lucida 40")
convert_label.pack()
select_mp3 = tk.Button(self, text="Select", font="lucida 15", command=self.convert_to_mp3)
select_mp3.pack()
def convert_to_mp3(self):
file = askopenfile(mode="r", filetypes=[('mp4 file', '*.mp4')])
mp4_file = file.name
mp3_file = mp4_file.replace("mp4", "mp3")
video = VideoFileClip(mp4_file)
audio = video.audio
audio.write_audiofile(mp3_file)
audio.close()
video.close()
showinfo(title="Done", message="Your mp4 file has been converted to mp3\nCheck your directory")
convert = Converter()
convert.mainloop()