有时候我们可能需要在python代码中批处理MP4转wav文件,操作如下:
for filepath in files:
filepath_no_ext = os.path.splitext(filepath)[0]
command = "ffmpeg -i"+" "+filepath+" "+"-ar 16000 -vn"+" "+filepath_no_ext+".wav"
print('command',command)
subprocess.call(command, shell=True)
print("the %dth sample number" % j )
j += 1
其中:
filepath为mp4的全路径
filepath_no_ext为去掉filepath中.wav的剩余路径