1.首先,安装moviepy
pip install moviepy -i https://pypi.tuna.tsinghua.edu.cn/simple
可能会遇到
问题1:
ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.
解决方法:
pip install --upgrade pip
pip install --upgrade setuptools
问题2:
ERROR: Cannot uninstall ‘imageio’. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall.
解决办法:
加上:–ignore-installed
pip install moviepy -i https://pypi.tuna.tsinghua.edu.cn/simple --ignore-installed
2.提取音频.mp4->.wav
from moviepy.editor import AudioFileClip
# 这里是MP4路径
my_audio_clip = AudioFileClip("C:/Users/ASUS/Downloads/Video/七里香(钢琴版).mp4")
# 这里是保存路径
my_audio_clip.write_audiofi