How to convert mp3 to ogg by php?

I use windows 7 and xampp in localhost.I want to convert mp3 audio to ogg audio by php script.I uploaded the zip file 'ffmpegConverter_v0.2', where the folder structure is:

ffmpegConverter_v0.2 --consoleConversor --consoleConversor --consoleConversor.exe --ffmpeg.dll --consoleMonitor --consoleMonitor --consoleMonitor.exe --ffmpeg.dll --Queue.xml --serviceConversor --ffmpeg.dll --serviceConversor --serviceConversor.exe --serviceMonitor --ffmpeg.dll --Queue.xml --serviceMonitor --serviceMonitor.exe --LEEME.txt --README.txt 

I save the folder "ffmpegConverter_v0.2", mp.php and "a.mp3" in the same folder and used the following code in the mp.php file:

 <?php exec("ffmpegConverter_v0.2\serviceConversor\serviceConversor.exe -i a.mp3 -acodec libvorbis ap.ogg"); ?> 

then the following error message appeared: enter image description here

What did I do wrong? What is the exact way to install ffmpeg? What exactly is the way to write a command in php script for this and how can this be used in an online server? is there any other better converter?

-Thanks.

EDIT:

when i used the following line

 <?php exec("ffmpegConverter_v0.2\consoleConversor\consoleConversor.exe -i a.mp3 -acodec libvorbis ap.ogg"); ?> 

then i got this message enter image description here

I also tried this:

 <?php exec("c:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe serviceConversor.exe"); exec("ffmpegConverter_v0.2\serviceConversor\serviceConversor.exe -i a.mp3 -vcodec libtheora -acodec libvorbis ap.ogg"); ?> 

it turned out the same message as the first image.

+7
source share
5 answers

Forget about this serviceConversor .

Get the FFmpeg build for Windows (a static build appropriate for your architecture should be a good start to avoid other problems with DLL / etc.) ..

Then use exec :

 <?php $retCode = exec('C:\\path\\to\\ffmpeg.exe -y -i file.mp3 -acodec libvorbis file.ogg'); ?> 

Remember to avoid backslashes ( \\ ); you are not in your question.

exec will return the return code FFmpeg (I put it in $retCode here), which is 0 for success.

As already noted, you can add the -aq option to set the OGG output quality for VBR transcoding.

libvorbis is built into the static version of FFmpeg; I just checked with ffmpeg.exe -codecs :

 DEA.L. vorbis Vorbis (decoders: vorbis libvorbis ) 

where DE stands for decoding and encoding for this codec.

+3
source

One of them should work:

 ffmpeg -y -i a.mp3 -acodec libvorbis -aq 50 output.ogg ffmpeg -i 1.mp4 -vcodec libtheora -acodec libvorbis testjohn4545454.ogg 
+2
source

do this in your own process and in the background, otherwise your PHP script will freeze, waiting for the conversion to complete.

The code:

 passthru("/usr/local/bin/ffmpeg -i 1.mp4 -vcodec libtheora -acodec libvorbistestjohn4545454.ogg 1> /path/to/logfile.txt 2>&1 &"); 
+2
source

The best advice I can give you:

If there is a README file, and something does not work. Read it!

In doing so, you try to run the command with serviceConversor.exe . This will not work as it is a Windows service and must be installed first. There is another file called consoleConverser.exe and, as README says, "It can be executed without a previous installation."

I assume you already have ffmpeg , which is required

So, your first option is to try and execute the correct command. Keep in mind that I am not familiar with this translator, so I have no idea if this is the right team. I am here to help with the error message.

 <?php exec("ffmpegConverter_v0.2\consoleConversor\consoleConversor.exe -i a.mp3 -acodec libvorbis ap.ogg"); ?> 

Now, if that fails, you can try the second part of readme. To install the Windows service. This must be done manually, which is explained in the ms knowledge base .

Unfortunately, serviceConversor was tested only with Windows XP, and I can’t install it on my Windows 7 system, but maybe you are more fortunate.

Now you say that you can directly call installutil serviceConversor.exe when you are in the ffmpegConverter_v0.2\serviceConversor\ folder using cmd , but most likely you will get a message saying that installutil could not be found. In this case, you can run it with the full path, which is usually one of them, depending on your version of .NET and when you run window 7 32 or 64.

 c:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe c:\Windows\Microsoft.NET\Framework\v4.0.30319\InstallUtil.exe c:\Windows\Microsoft.NET\Framework64\v2.0.50727\InstallUtil.exe c:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe 

So, in my case, the full command would be (from the serviceConversor folder)

 c:\Windows\Microsoft.NET\Framework64\v4.0.30319\InstallUtil.exe serviceConversor.exe 
+1
source

MP3-> OGG

 ffmpeg -i input.mp3 -ab 6400 output.ogg 

OGGDEC.EXE OGG-> MP3

 OGGDEC.EXE myfile.ogg --stdout | LAME.EXE -V5 --vbr-new - myfile.mp3 
+1
source

All Articles