PHP - 将 .wav 文件转换为 .mp3?
我想知道是否有人对将用户上传的 .wav 文件编码为 .mp3 扩展名有任何建议。如果可能的话,我想构建一个 PHP 解决方案。文件上传后,我可以通过 PHP 调用命令行 LAME 编码器吗?有更好的选择吗?
谢谢!
I was wondering if anyone had any advice for encoding a user uploaded .wav file to a .mp3 extension. I would like to build a PHP solution if possible. Can I call the command line LAME encoder via PHP once a file has been uploaded? Is there a better option?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
继续打电话给 LAME。没有更好的选择存在,如果考虑到编码器的质量则更是如此。
调用外部二进制文件的最简单方法是
exec
< /a>,而为了在编码过程中实现最佳集成,您可能需要使用proc_open
。Go ahead and call LAME. No chance of a better option existing, even more so if you take the encoder quality into account.
The easiest way to call into an external binary is
exec
, while for the best integration over the encoding process you might want to useproc_open
.我为 LAME 编写了一个包装器,它提供了方便的接口来编码 wav 文件。该库位于此处:https://github.com/b-b3rn4rd/phplame
I wrote a wrapper for LAME that provides convenient interface to encode wav file(s). The library is available here: https://github.com/b-b3rn4rd/phplame
我这样做,我下载并安装了 ffmpeg 和 libmp3lame。
在您的代码中执行以下操作:
I do this, I downloaded and installed ffmpeg with libmp3lame.
In your code do this: