Alex Pliutau
Alex Pliutau

Reputation: 21937

Convert audio files in 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.

Upvotes: 4

Views: 25150

Answers (4)

Mythli
Mythli

Reputation: 6315

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.

Upvotes: -1

llogan
llogan

Reputation: 134183

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.

Upvotes: 1

johndodo
johndodo

Reputation: 18291

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).

Upvotes: 0

Ivelin
Ivelin

Reputation: 13329

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/

Upvotes: 18

Related Questions