Reputation: 1868
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.
Upvotes: 7
Views: 7867
Reputation: 7575
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.
Upvotes: 3
Reputation: 977
execute this in it's own process and in the background, otherwise your PHP script will hang whilst 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 &");
Upvotes: 2
Reputation: 13586
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
Upvotes: 1
Reputation: 14163
The best advise I can give you:
If there is a README file, and something is not working. Read it!
That being said, you are trying to run a command against serviceConversor.exe
. That will not work as this is a windows service and it needs to be installed first. There is also another file called consoleConverser.exe
and, as the README file says, 'Can be executed without previous installation.'.
I'm assuming that you already have ffmpeg installed as that is required
So your first option would be to try and execute the right command like. Keep in mind that I'm not familiar with this conversor, so I have no idea if this is the right command. I'm here to help with the error message.
<?php
exec("ffmpegConverter_v0.2\consoleConversor\consoleConversor.exe -i a.mp3 -acodec libvorbis ap.ogg");
?>
Now if this fails you can still try the second part of the readme. Which is to install the windows service. This has to be done manually, which is explained in the ms knowledgebase.
Unfortunately the serviceConversor has only been tested with Windows XP and I can not install it on my Windows 7 system, but perhaps you have more luck.
Now this says you can directly call installutil serviceConversor.exe
when you are in the ffmpegConverter_v0.2\serviceConversor\
folder using cmd
, but chances are you will get a message saying that installutil could not be found. In that case you can run it with the full path, which is normally one of these, depending on your .NET version and if you are running 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
Upvotes: 1
Reputation: 2095
One of these should work:
ffmpeg -y -i a.mp3 -acodec libvorbis -aq 50 output.ogg
ffmpeg -i 1.mp4 -vcodec libtheora -acodec libvorbis testjohn4545454.ogg
Upvotes: 2