Python库无需转码即可修改MP3音频 [英] Python library to modify MP3 audio without transcoding

查看:172
本文介绍了Python库无需转码即可修改MP3音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在开始一个小项目之前,我正在寻找有关mp3格式的一些常规建议,以确保我不被追逐.

I am looking for some general advice about the mp3 format before I start a small project to make sure I am not on a wild-goose chase.

我对mp3格式的内部了解很少.理想情况下,我正在寻找一个可以将这些细节抽象化的库.我更喜欢使用Python(但可以确信).

My understanding of the internals of the mp3 format is minimal. Ideally, I am looking for a library that would abstract those details away. I would prefer to use Python (but could be convinced otherwise).

我想以一种非常简单的方式修改一组mp3文件.我对ID3标签不是很感兴趣,但对音频本身很感兴趣.我希望能够删除部分(例如,从第三分钟起下降10秒),并插入部分(例如,在末尾添加点数.)

I would like to modify a set of mp3 files in a fairly simple way. I am not so much interested in the ID3 tags but in the audio itself. I want to be able to delete sections (e.g. drop 10 seconds from the 3rd minute), and insert sections (e.g. add credits to the end.)

我的理解是mp3格式是有损的,因此将其解码为(例如)PCM格式,进行修改,然后再次将其编码为MP3会降低音频质量. (我很想听到我错了.)

My understanding is that the mp3 format is lossy, and so decoding it to (for example) PCM format, making the modifications, and then encoding it again to MP3 will lower the audio quality. (I would love to hear that I am wrong.)

猜想,如果我保持mp3格式,将有某种最小帧或数据包大小需要处理,因此操作的粒度可能会更粗糙.只要我能在几秒钟之内获得准确的结果,我就可以接受.

I conjecture that if I stay in mp3 format, there will be some sort of minimum frame or packet-size to deal with, so the granularity of the operations may be coarser. I can live with that, as long as I get an accuracy of within a couple of seconds.

我查看了 PyMedia ,但是它要求我迁移到PCM来处理数据.同样, LAME 希望帮助我进行编码,但不能就地访问数据.我看过其他一些只处理ID3标签的库.

I have looked at PyMedia, but it requires me to migrate to PCM to process the data. Similarly, LAME wants to help me encode, but not access the data in place. I have seen several other libraries that only deal with the ID3 tags.

有人可以推荐Python MP3库吗?另外,您是否可以使我不相信去PCM并返回是不好且可以避免的假设?

Can anyone recommend a Python MP3 library? Alternatively, can you disabuse me of my assumption that going to PCM and back is bad and avoidable?

推荐答案

我得到了三个高质量的答案,我感谢你们所有人(并支持你们所有人).我没有选择任何一个作为接受的答案,因为每个都针对一个方面,所以我想写一个摘要.

I got three quality answers, and I thank you all (and upvoted you all) for them. I haven't chosen any as the accepted answer, because each addressed one aspect, so I wanted to write a summary.

您需要使用MP3吗?

  • 转码为PCM并重新转换为MP3不太可能导致质量下降.

  • Transcoding to PCM and back to MP3 is unlikely to result in a drop in quality.

不要过早优化音频质量;用一个简单的原型对其进行测试并聆听.

Don't optimise audio-quality prematurely; test it with a simple prototype and listen to it.

使用MP3

MP3帧很短(1152个样本,或仅几毫秒),因此在该级别上具有中等精度.

MP3 frames are short (1152 samples, or just a few milliseconds) allowing for moderate precision at that level.

但是,维基百科警告框架不是独立的项目(字节库"),因此无法在任意框架边界上提取."

However, Wikipedia warns that "Frames are not independent items ("byte reservoir") and therefore cannot be extracted on arbitrary frame boundaries."

如果我真的想避免解码,则现有的库不太可能提供帮助.

Existing libraries are unlikely to be of assistance, if I really want to avoid decoding.

使用PCM

此级别有几个库:

  • LAME (最新版本:2017年10月)
  • PyMedia (最新版本:2006年2月)
  • PyMad (仅Linux?仅解码器?最新版本:2007年1月)
  • LAME (latest release: October 2017)
  • PyMedia (latest release: February 2006)
  • PyMad (Linux only? Decoder only? Latest release: January 2007)

更高级别的工作

  • Echo Nest Remix API (目前仅适用于Mac或Linux)是一种Web服务的API,支持相当复杂的操作(例如,查找音乐节拍和拍子的位置等)

  • Echo Nest Remix API (Mac or Linux only, at the moment) is an API to a web-service that supports quite sophisticated operations (e.g. finding the locations of music beats and tempo, etc.)

mp3DirectCut (仅适用于Windows)是一种GUI,显然可以执行我想要的操作,但是作为一个应用程序.它不是开源的. (我尝试运行它,但出现访问被拒绝"安装程序错误,并且没有进行后续操作.GUI不适合我,因为我想在不断变化的文件库中重复运行这些操作.)

mp3DirectCut (Windows only) is a GUI that apparently performs the operations I want, but as an app. It is not open-source. (I tried to run it, got an Access Denied installer error, and didn't follow up. A GUI isn't suitably for me, as I want to repeatedly run these operations on a changing library of files.)

我的计划是现在开始使用PCM在PyMedia中.谢谢大家的帮助.

My plan is now to start out in PyMedia, using PCM. Thank you all for your assistance.

这篇关于Python库无需转码即可修改MP3音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆