Python教程

python——AudioSegment 读取mp3文件报错:Python AudioSegment winError 2 The system cannot find the file speci

本文主要是介绍python——AudioSegment 读取mp3文件报错:Python AudioSegment winError 2 The system cannot find the file speci,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

今天运行一个声音混合的程序,使用python 的AudioSegment.from_mp3(mp3path) 报错了.

我百度了一下说是缺少文件ffmpeg.exe和ffprobe.exe然后我就下载了windows的【https://github.com/BtbN/FFmpeg-Builds/releases?page=3】

我用的是python3.6,下载了好几个

 

 使用第一种方案:

直接在代码中添加

    AudioSegment.converter = r"E:\s\ffmpeg-N-104843-gf176669a37-win64-lgpl-shared\ffmpeg-N-104843-gf176669a37-win64-lgpl-shared\bin\ffmpeffmpeg.exe"
    AudioSegment.ffprobe = r"E:\s\ffmpeg-N-104843-gf176669a37-win64-lgpl-shared\ffmpeg-N-104843-gf176669a37-win64-lgpl-shared\bin\ffprobe.exe"
    

  然后运行,,失败,尝试了三个都失败了。。。

使用第二中方案:

直接复制这两个exe文件到项目运行目录,使用第三个失败了。。

然后使用第二个里面的两个exe文件成功了!!!我都快放弃了~竟然成功了

 

附:

 音频混合(不是拼接):

 

    sound1 = AudioSegment.from_mp3("E:\\s\\CodeEditer\\1.mp3")
    sound2 = AudioSegment.from_mp3("E:\\s\\CodeEditer\\2.mp3")
    combined = sound1.overlay(sound2)
    combined.export("3.mp3", format='mp3')

  

参考:

https://blog.csdn.net/xiaoxifei/article/details/105295288

https://www.jianshu.com/p/75cbbefca085

 

这篇关于python——AudioSegment 读取mp3文件报错:Python AudioSegment winError 2 The system cannot find the file speci的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!