在 python 中将 mp3 转码为 ogg 的简单方法(实时)?
我正在寻找一个可以将 MP3(其他格式更佳)转码为 OGG 的库/模块。
我需要这个的目的:我正在编写一个相对较小的网络应用程序,供个人使用,它允许人们通过浏览器听音乐。对于听力部分,我打算使用新的强大的 标签。然而,很少有浏览器支持 MP3。实时转码似乎是最好的选择,因为它不会浪费磁盘空间(就像我要转换整个音乐库一样),而且不会出现性能问题,因为同时最多有 2-3 个听众。
基本上,我需要向它提供一个 MP3(或其他任何东西),然后获取一个类似文件的对象,我可以将其传回我的框架(顺便说一句,flask
)以提供给客户端。
我看过的东西:
gstreamer
——虽然对很多格式都有很好的支持,但似乎有点过分了;文档严重缺乏timeside
- 看起来不错且易于使用,但它又有很多我不需要的东西(绘图、分析、UI...)- PyMedia --最后更新:2006 年 2 月 1 日...
有建议吗?
I'm searching for a library / module that can transcode an MP3 (other formats are a plus) to OGG, on the fly.
What I need this for: I'm writing a relatively small web app, for personal use, that will allow people to listen their music via a browser. For the listening part, I intend to use the new and mighty <audio>
tag. However, few browsers support MP3 in there. Live transcoding seems like the best option because it doesn't waste disk space (like if I were to convert the entire music library) and I will not have performance issues since there will be at most 2-3 listeners at the same time.
Basically, I need to feed it an MP3 (or whatever else) and then get a file-like object back that I can pass back to my framework (flask
, by the way) to feed to the client.
Stuff I've looked at:
gstreamer
-- seems overkill, although has good support for a lot of formats; documentation lacks horriblytimeside
-- looks nice and simple to use, but again it has a lot of stuff I don't need (graphing, analyzing, UI...)- PyMedia -- last updated: 01 Feb 2006...
Suggestions?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您知道,使用
subprocess
调用外部实用程序并不丢人。例如,您可以构建如下管道:事实上,无论如何,这可能是您最好的方法。考虑到在多 CPU 系统上,MP3 解码器和 OGG 编码器将在单独的进程中运行,并且可能会在单独的内核上进行调度。如果您尝试对单线程库执行相同的操作,则转码速度只能与单核处理速度一样快。
You know, there's no shame in using
subprocess
to call external utilities. For example, you could construct pipes like:In fact, that's probably your best approach anyway. Consider that on a multi-CPU system, the MP3 decoder and OGG encoder will run in separate processes and will probably be scheduled on separate cores. If you tried to do the same with a single-threaded library, you could only transcode as fast as a single core could handle it.