How to compress or convert to low quality Mp3 file from PHP [closed]

旧街凉风 提交于 2019-12-18 13:28:07

问题


Is there any PHP library or function to covert Mp3 file to lower quality?

I want to compress / convert 128Kbps or higher quality Mp3 file to 64Kbps Mp3 file by PHP.

Anyone know?


回答1:


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

Then, make sure you have safe mode enabled in your PHP configuration and select the right dir where you can execute files: safe_mode_exec_dir

Finally, use:

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



回答2:


Have you taken a look at ffmpeg? http://ffmpeg-php.sourceforge.net/




回答3:


keep in mind php can easily execute shell commands or scripts, so calling external programs opens many possibilities.

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




回答4:


This command worked for me

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



回答5:


To my way of thinking, to compress a mp3 music file, means reducing the weight in MB. You make the mp3 portable so that you can email it. You can half the MB by converting it from stereo to mono, you throw one sound track away. On the small speakers of my desktop PC computer I honesty can not hear the difference between a (4 MB) 128 kbps stereo mp3 and a (1 MB) 32 kbps mono mp3 music file. So, if you really want to compress a mp3 music 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 voted down. Not without reason. What I forgot to say, is that a 16 kbps mono MP3 sounds a lot better than a 16 kbps stereo. Maybe you don’t compress the MP3 by converting it from stereo to mono, but you maintain better sound quality, allowing you to compress the MP3 further. I did this for years when I still had dial-up internet, I had to, to enable me to email an MP3. Sorry for the oversight, I simply forgot ... it was years ago.



来源:https://stackoverflow.com/questions/4628221/how-to-compress-or-convert-to-low-quality-mp3-file-from-php

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!