Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can convert mp3 to ogg by php?

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 : enter image description here

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 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");
?>

then got the same message like the first picture.

like image 790
user1844626 Avatar asked Jun 02 '13 00:06

user1844626


People also ask

Can VLC convert MP3 to OGG?

This free software also allows users to convert, stream and play most types of multimedia files. To convert MP3 to OGG Vorbis using VLC follow these 3 easy steps. Step 1: Launch VLC and navigate to Media > Convert/Save. Step 2: Add your MP3 file and then click on the Convert/Save button.

Can audacity convert MP3 to OGG?

You can convert any audio file supported to Audacity to 3 files types: MP3, WAV, and Ogg Vorbis. From Audacity, click "Project" > Select "Import Audio." Navigate to the file you want to convert > Click [Open].

How much does it cost to convert MP3 to Ogg?

Our MP3 to OGG Converter is free and works on any web browser. We guarantee file security and privacy. Files are protected with 256-bit SSL encryption and automatically deleted after 2 hours. What is an MP3 (MPEG-1 Audio Layer III or MPEG-2 Audio Layer III) file?

How do I play ogg files on my computer?

The used codecs supports variable bit rates (as a default), and .ogg files usually play back easily on all platforms. All things being equal, the sound quality exceeds that of mp3 somewhat. Select files from Computer, Google Drive, Dropbox, URL or by dragging it on the page.

What is an Ogg (Ogg Vorbis) file?

What is an OGG (Ogg Vorbis) file? Ogg Vorbis (OGG) is a file that uses Ogg Vorbis compression. OGG is a patent-free, royalty-free encoding scheme provided by the Xiph.Org Foundation. Like MP3, OGG files are renowned for their high quality. OGG files include metadata, as well as artist and track title information.

What are MP3 files and how to open them?

MP3 files are the most widely-used audio file for consumers. Due to small size and acceptable quality, MP3 files are accessible to a wide audience, as well as easy to store and share. How to open an MP3 file? Because MP3 files are so prevalent, most major audio playback programs support them.


1 Answers

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.

like image 186
eepp Avatar answered Sep 24 '22 11:09

eepp