需求:先把把视频素材用 无损视频裁剪合并编辑工具SolveigMM Video Splitter Business Edition 5 剪切成很多段mp4,然后用这个脚本提取所有mp4的音频
import os #批量导出MP4的音频 indir = "G:/PythonIO/video" def dirlist(path, allfile): filelist = os.listdir(path) for filename in filelist: #广义 filepath = os.path.join(path, filename) if os.path.isdir(filepath): dirlist(filepath, allfile) elif filepath.endswith("mp4"): filepath = filepath.replace("\\","/") allfile.append(filepath) print(filepath) return allfile allfile = dirlist(indir,[]) i = 1 for infile in allfile: os.system("ffmpeg -i \""+ infile +"\" -f mp3 "+str(i)+".mp3") i+=1
文章来源: https://blog.csdn.net/wsl985/article/details/90344597