不能用conda安装:
pip install ffmpy3
下载 ffmpeg.exe :Download FFmpeg , 假定解压到 C:\ffmpeg-6.1.1-essentials_build
# -*- coding: utf-8 -*-
import os
from ffmpy3 import FFmpeg
def mp4_2_mp3(mp4_file_name):
# mp4文件放在脚本同一目录
filepath = os.getcwd()
mp4filepath = os.path.join(filepath,mp4_file_name)
mp3filepath=mp4filepath.replace('.mp4', '.mp3')
ff = FFmpeg(executable='C:\\ffmpeg-6.1.1-essentials_build\\bin\\ffmpeg.exe',
inputs={mp4filepath: None},
outputs={mp3filepath: None})
print(ff.cmd)
ff.run()
print('done')
if __name__=="__main__":
mp4_file_name='小城夏天.mp4'
mp4_2_mp3(mp4_file_name)
正文完