首页 > 解决方案 > 使用python将webm转换为mp3?

问题描述

是的,我知道这已经被问过很多次了,但是每个答案的库最终都需要 ffmepg。

问题在于,当我将 ffmpeg 包含到我的项目中时,文件大小会急剧增加,而我只是不希望这样。

我想让我的项目尽可能地轻量级,而不需要添加 200 兆字节的数据来仅用于视频到音频的转换,这只是项目的一小部分。

那么有什么办法可以

标签: pythonpython-3.xffmpeglightweight-processes

解决方案


使用此配置编译您自己的ffmpeg以在 WebM 中解码 Vorbis/Opus 音频并通过 libmp3lame 编码 MP3:

./configure --disable-everything --disable-network --disable-autodetect --enable-small --enable-protocol=file,pipe --enable-demuxer=matroska --enable-muxer=mp3 --enable-decoder=vorbis,opus --enable-encoder=libmp3lame --enable-libmp3lame --enable-filter=aresample

生成的大小ffmpeg小于 2 MB。


推荐阅读