I'm using windows 7 and xampp in localhost.I want to convert mp3 audio into ogg audio by php script.I downloaded 'ffmpegConverter_v0.2' zip file 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 keep the 'ffmpegConverter_v0.2' folder,mp.php and 'a.mp3' in same folder and used the following code in mp.php:
<?php
exec("ffmpegConverter_v0.2\serviceConversor\serviceConversor.exe -i a.mp3 -acodec libvorbis ap.ogg");
?>
then got the following error message :
what wrong did I do ? whats the exact way to install ffmpeg ? whats the exact way to write the command in php script for that and how can that be used in online server ? is there any other better converter else ?
-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
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");
?>
then got the same message like the first picture.
Forget about that serviceConversor
thing.
Get an FFmpeg build for Windows (a static build that matches your architecture should be a good start to avoid other DLL/etc. problems).
Then use exec
:
<?php
$retCode = exec('C:\\path\\to\\ffmpeg.exe -y -i file.mp3 -acodec libvorbis file.ogg');
?>
Don't forget to escape the backslashes (\\
); you didn't in your question.
exec
will return the return code of FFmpeg (I put it in $retCode
here), which is 0 for a success.
As some noted, you can add the -aq
option to set the OGG output quality for a VBR transcoding.
libvorbis is built in the static FFmpeg version; I just checked using ffmpeg.exe -codecs
:
DEA.L. vorbis Vorbis (decoders: vorbis libvorbis )
where DE means decoding and encoding are supported for this codec.