在 PHP 中转换音频文件
我需要将 AMR 音频文件转换为 MP3。我如何在没有 FFMPEG 的情况下用 PHP 制作它(我没有在服务器上安装它的权限)。请帮我。
I need to convert AMR audio file to MP3. How can I make it in PHP without FFMPEG (i have no permissions to install it on the server). Please help me.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
使用SoX——声音处理的瑞士军刀。非常容易使用。
它是一个命令行工具,而不是 PHP 库,因此要从 PHP 中使用,您需要执行 shell 命令并在代码中获取结果。我在几个项目中使用过它。
以 PHP 为例:
SoX 是一个跨平台(Windows、Linux、MacOS X 等)命令行实用程序,可以将各种格式的计算机音频文件转换为其他格式。它还可以对这些声音文件应用各种效果,而且,作为额外的好处,SoX 可以在大多数平台上播放和录制音频文件。
SoX是非常成熟的项目!这是链接:http://sox.sourceforge.net/
以下是我在谷歌上为您搜索的一些示例:
http://www.thegeekstuff.com/2009 /05/sound-exchange-sox-15-examples-to-manipulate-audio-files/
Use SoX - the Swiss Army knife of sound processing. Very easy to use.
It is a command line tool not a PHP library so to use from PHP you need to execute a shell command and get the result with in your code. I have used it with in few projects.
Example with PHP:
SoX is a cross-platform (Windows, Linux, MacOS X, etc.) command line utility that can convert various formats of computer audio files in to other formats. It can also apply various effects to these sound files, and, as an added bonus, SoX can play and record audio files on most platforms.
SoX is very mature project! Here is the link: http://sox.sourceforge.net/
Here are some examples I googled for you:
http://www.thegeekstuff.com/2009/05/sound-exchange-sox-15-examples-to-manipulate-audio-files/
只需使用
ffmpeg
。您可以简单地下载ffmpeg
(寻找“静态构建”)的二进制文件,然后将您的脚本指向二进制。无需安装它,因此不应存在许可问题。Just use
ffmpeg
. You can simply download a binary offfmpeg
(look for "static builds"), and then point your script to the binary. There is no need to install it so there should be no permission issues.AFAIK 没有办法,至少没有其他命令行实用程序。您可以尝试使用 mplayer,但我想这里的情况与 ffmpeg 相同。 :)
如果您的主机策略允许(安全模式、SELinux),您当然可以上传可执行文件并通过 PHP 运行它。
AFAIK there is no way, at least without other command line utilities. You could try using mplayer, but I guess the situation here is the same as with ffmpeg. :)
You could of course upload the executable and run it through PHP if your host's policies allow this (safe mode, SELinux).
简单回答:您无法用纯 PHP 转换音频文件。我建议您创建/搜索网络服务来完成该任务。
Simple answer: You can't convert audio files in pure PHP. I would suggest you to create/ search for a web-service to accomplish that task.