How to compress or convert a low quality Mp3 file from PHP

Is there a library or PHP function for a hidden Mp3 file to reduce quality?

I want to compress / convert 128 Kbit / s or better Mp3 file to Mp3 file in 64 Kbit / s in PHP.

Somebody knows?

+7
source share
5 answers

First of all, you need to install ffmpeg, available at: http://ffmpeg.org/download.html

Then, make sure that safe mode is enabled in your PHP settings and select the necessary directory where you can execute files: safe_mode_exec_dir

Finally use:

exec("ffmpeg -i inputfile.mp3 -ab 64 outputfile.mp3") 
+10
source

Have you watched ffmpeg? http://ffmpeg-php.sourceforge.net/

+4
source

remember that php can easily execute shell commands or scripts, so calling external programs opens up many possibilities.

http://php.net/manual/en/ref.exec.php

+2
source

This team worked for me.

 exec("ffmpeg -i inputfile.mp3 -b:a 64k outputfile.mp3") 
+2
source

To my way of thinking, to compress an mp3 music file, I need to reduce the weight in MB. You make mp3 portable so that it can be sent by email. You can make half MB by converting it from stereo to mono, you will throw out one audio track. On the small speakers of my PC computer, I honestly don’t hear the difference between stereo sound (4 Mb) and 128 Mb / s and mp3 file (1 MB) at 32 Kb / s. So, if you really want to compress the mp3 file, I would suggest the following ffmpeg, where -ac 1 means one audio channel (mono). exec ("ffmpeg -i inputfile.mp3 -ab 32k -ac 1 outputfile.mp3")

I noticed that my comment was rejected. No wonder. I forgot to say that 16 kbps monaural MP3 is much better than 16 kbps stereo. You may not compress MP3 by converting it from stereo to mono, but you maintain better sound quality, which allows you to compress MP3 further. I did this for many years, when I still had dial-up Internet access, I had to so that I could send an email in MP3. Sorry for the oversight, I just forgot ... it was many years ago.

-one
source

All Articles