如何使用python将mp4转换为mp3

时间:2019-03-09 19:51:42

标签: python audio mp3

如何使用python将mp4或mpeg4文件转换为mp3?

我看过几个没有成功的库。

1 个答案:

答案 0 :(得分:1)

这听起来像是MoviePy的任务。安装它(installation howto)后,可以按以下方式使用它:

import os
from moviepy.editor import *
video = VideoFileClip(os.path.join("path","to","movie.mp4"))
video.audio.write_audiofile(os.path.join("path","to","movie_sound.mp3"))

只需根据需要替换"path","to","movie.mp4""path","to","movie_sound.mp3"