##coding:utf-8
import os
import moviepy.editor as mpy
for name in os.listdir(r"C:\Users\Administrator\Desktop\part2"): ##读取文件夹下的所有文件
if name.endswith('.mp4'): ##读取所有mp4文件
old_path = r"C:\Users\Administrator\Desktop\part2\{}".format(name) #mp4文件路径
audio_background = mpy.AudioFileClip(old_path) #添加处理
new_path = r"C:\Users\Administrator\Desktop\part2mp3\{}".format(name).replace("mp4","mp3") #输出mp3路径
audio_background.write_audiofile(new_path) #处理mp3
print("完成",name)
网友评论