一.环境配置
https://ffmpeg.org/download.html#build-windows
#选择对于系统
如果是windows直接访问一下连接
https://github.com/BtbN/FFmpeg-Builds/releases
选择xxx-shared.zip
https://github.com/BtbN/FFmpeg-Builds/releases/download/autobuild-2020-09-27-12-31/ffmpeg-N-99395-ga3a6b56200-win64-gpl-shared.zip
#再解压把ffmpeg.exe所在路径配置环境变量中
二.命令行执行代码
ffmpeg -i 1.mp3 -f s16be -ar 16000 -ac 1 -acodec pcm_s16be 1.pcm
三.python执行代码
from ffmpy import FFmpeg
#将mp3转化没pcm
ff = FFmpeg(inputs={r'd: est1.mp3':"-i"},
outputs={r'd: est1.pcm':"-f s16be -ar 16000 -ac 1 -acodec pcm_s16be"})
print(ff.cmd)
ff.run()
#将pcm转化为mp3
ff1 = FFmpeg(inputs={r'd: est1.pcm':"-f s16be -ar 16000 -ac 1 -acodec pcm_s16be"},
outputs={r'd: est1.mp3':None})
print(ff1.cmd)
ff1.run()
四.参考文档
参数说明:https://blog.csdn.net/weixin_33890499/article/details/88708622