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.
问题:
回答1:
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:
<?php
exec('sox /mypath/my_audio.amr /mypath/my_audio.mp3');
?>
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/
回答2:
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).
回答3:
Just use ffmpeg
. You can simply download a binary of ffmpeg
(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.
回答4:
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. (For example: maybe you can make use of this through curl).