# from the tkinter library
from tkinter import *
# import filedialog module
from tkinter import filedialog
# install moviepy using pip install moviepy
import moviepy
import moviepy.editor
from PIL import Image, ImageTk
root=Tk()
root.title('Mp4 to Mp3 @_python.py_')
root.geometry("400x380")
root.config(bg="#ffffff")
root.iconbitmap("audio-converting.ico")
image1 = Image.open('MP4toMP3.png')
test = ImageTk.PhotoImage(image1)
Label(image = test, bg='#ffffff').pack()
Label(root, text = 'MP4 to MP3', fg="#404042", bg="#ffffff", font="Verdana 20 bold").pack()
Label(root, text = '@_python.py_', fg="#404042", bg="#ffffff", font="Verdana 10 bold").pack()
# Function for opening the
def browseFiles():
global filename
filename=filedialog.askopenfilename(initialdir="/", title="Select a File",
filetypes=(("Text files", "*.Mp4*"), ("all files", "*.*")))
# Change label contents
label_file_explorer.configure(text="File : "+filename)
# Function for convert Mp4 to Mp3
def changetomp3():
video=moviepy.editor.VideoFileClip(filename) # Put your file path in here
# Convert video to audio
audio=video.audio
audio.write_audiofile(f'{filename}.mp3')
label_file_explorer = Label(root, text="Choose File", width=50, height=2, fg="blue")
label_file_explorer.pack(anchor='center', pady=5)
Button(root, text="Browse Files", command=browseFiles, fg="#ffffff", bg="#404042",
font="Verdana 10 bold").place(x = 50, y= 250)
Button(root, text="Convert", width=12, command=changetomp3, fg="#ffffff", bg="#404042",
font="Verdana 10 bold").place(x = 210, y= 250)
Button(root, text="Exit", width=12,command=exit, fg="#ffffff", bg="#404042",
font="Verdana 10 bold").place(x = 130, y= 290)
root.mainloop()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
这里介绍一个使用python的moviepy和tkinter库实现的MP4文件转换Mp3的小工具。首先,使用moviepy库实现MP4到Mp3的格式转换。moviepy是一个用于视频编辑的python库,它支持读取和写入各种视频格式,包括MP4和Mp3。利用moviepy的AudioFileClip和AudioClip可以很方便地从MP4文件中提取音轨,并将其保存为Mp3格式。然后,使用tkinter库构建一个简单的GUI界面。tkinter是python内置的GUI库,可以方便地创建窗口、按钮、输入框等GUI组件。这里创建了一个主窗口,添加打开文件按钮、保存路径输入框和转换按钮。当用户选择需要转换的MP4文件后,程序会利用moviepy从文件中读取AudioClip,然后利用AudioClip的write_audiofile方法将音频写入Mp3格式。转换完成后提示用户转换成功。整个小工具只需几十行python代码就可以实现MP4到Mp3的自动转换功能。用户通过简单的GUI操作选择文件和路径,点击转换按钮即可一键完成音频格式转换,无需复杂的编解码设置。这对一般用户来说操作更友好更便利。
资源推荐
资源详情
资源评论
收起资源包目录
python的moviepy和tkinter库实现的MP4 文件转换Mp3工具源代码.zip (4个子文件)
python的moviepy库实现的MP4 文件转换Mp3工具源代码
output.jpg 29KB
MP4toMP3.png 9KB
Mp4toMp3.py 2KB
audio-converting.ico 66KB
共 4 条
- 1
资源评论
传奇开心果编程
- 粉丝: 8104
- 资源: 335
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 基于MFC的校园导航程序(使用最短路径dijkstra算法).rar
- Android Studio android APP 视频作为视图背景需要源代码或想了解其实现原理的可以私心我
- com.ZeroneGames.GreenProject.apk
- Python自动化开发入门教程
- 4399GameSem_116_13955_207551_6.apk
- python 3.9.19源码编译包
- php-8.2.18-Win32-vs16-x64.rar
- 字节跳动青训营-抖音项目
- SQL资料手册,语句教程,高级查询语句语法
- 上位机和串口建立 Modbus 协议进行数据传输,并使用 Mysql 数据库存储,能够实现实时温湿度显示和动态变化曲线,历史数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功