| import os |
| import filetype |
| import moviepy.editor as mpy |
| import time |
| |
| |
| videopath="D:/video/" |
| musicpath = "D:/music/" |
| |
| |
| videofile=os.listdir(videopath) |
| |
| |
| def getName(video_name): |
| return os.path.basename(video_name).split('.')[0] |
| |
| |
| def showfile(): |
| for i in videofile: |
| print(i) |
| |
| |
| def extract(): |
| num=0 |
| for i in videofile: |
| name=getName(i) |
| newname=str(name)+".mp3" |
| audio = mpy.VideoFileClip(videopath+str(i)).audio |
| audio.write_audiofile(musicpath+newname) |
| print(name+"已经提取完成"+"--------当前为第"+str(num)+"个文件") |
| |
| key="0" |
| while(key!="3"): |
| key=input("输入1读取当前列表、输入2开始提取音频、输入3退出") |
| if key=="1": |
| showfile() |
| if key=="2": |
| extract() |
| if key=="3": |
| break |