In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces "PHP how to convert amr audio files to mp3 format" related knowledge, Xiaobian through the actual case to show you the operation process, the operation method is simple and fast, practical, I hope this article "PHP how to convert amr audio files to mp3 format" article can help you solve the problem.
Tell me the whole idea.
1, Server installation ffmpeg
2. Use ffmpeg -i command to convert amr to mp3 format (this will be written in PHP code at that time, and can be executed using exec function)
3. Use HTML5 audio tag to play mp3 files on the web side
Here are the operational details:
1. Server installation ffmpeg Take centos as an example
Reference here: http://my.oschina.NET/ethan09/blog/372435
It is important to note that in the following method, amrnb and amrwb install to make link will request a URL of 3gp, generally not requested, you can use crtl+c to cancel his process, and these two do not need to be able to convert the format.
Received requirements to convert amr to mp3 in Linux environment, windows directly using the third-party jar package exe method can, but does not support Linux, Internet crawling information that is using ffmpeg plus amr plug-in can be achieved, according to the tutorial tried:
1. First install the system compilation environment
yum install -y automake autoconf libtool gcc gcc-c++ #CentOS
2. Compile the required source packages
#yasm: assembler, new version of ffmpeg adds assembly code wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gztar-xzvf yasm-1.3.0.tar.gzcd yasm-1.3.0./ configuremake install#lame: Mp3 audio decode wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gztar-xzvf lame-3.99.5.tar.gzcd lame-3.99.5./ configuremake install#amr support wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gztar-xzvf opencore-amr-0.1.3.tar.gzcd opencore-amr-0.1.3./ configuremake install#amrnb support wget http://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2tar-xjvf amrnb-11.0.0.tar.bz2cd amrnb-11.0.0.0./ configuremake install#amrwb support wget http://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2tar-xjvf amrwb-11.0.0.tar.bz2cd amrwb-11.0.0.0./ configuremakemake install#ffmpegwget http://ffmpeg.org/releases/ffmpeg-2.5.3.tar.bz2tar -xjvf ffmpeg-2.5.3.tar.bz2cd ffmpeg-2.5.3./ configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-sharedmakemake install#Load configuration #After finally writing config, the terminal runs ffmpeg command, success and installed extensions appear, and the operation succeeds. ldconfig
3. use method
ffmpeg -i 1.mp3 -ac 1 -ar 8000 1.amr #MP3 to AMR ffmpeg -i 1.amr 1.mp3 #AMR to MP3
Appendix:
Appendix 1. ffmpeg default installation directory is "/usr/local/lib", some 64-bit system software directory is "/usr/lib64", may appear during compilation process
ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory
# ln -s /usr/local/lib/libmp3lame.so.0.0.0 /usr/lib64/libmp3lame.so.0
Appendix 2. ffmpeg: error while loading shared libraries: libavdevice.so.54: cannot open shared object file: No such file or directory
You can see which of ffmpeg's dynamic link libraries are not found by:
ldd `which ffmpeg` libavdevice.so.54 => not found libavfilter.so.3 => not found libavformat.so.54 => not found libavcodec.so.54 => not found libswresample.so.0 => not found libswscale.so.2 => not found libavutil.so.51 => not found libm.so.6 => /lib64/libm.so.6 (0x00002ab7c0eb6000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00002ab7c100b000) libc.so.6 => /lib64/libc.so.6 (0x00002ab7c1125000) /lib64/ld-linux-x86-64.so.2 (0x00002 ab7c0d9a000)#If the output is similar to the above, look up the above libraries and you will find them all under/usr/local/lib/find /usr/local/lib/| grep -E "libavdevice.so.54| libavfilter.so.3| libavcodec.so.54"/usr/local/lib/libavfilter.so.3.17.100/usr/local/lib/libavcodec.so.54.59.100/usr/local/lib/libavdevice.so.54/usr/local/lib/libavcodec.so.54/usr/local/lib/libavfilter.so.3/usr/local/lib/libavdevice.so.54.2.101#Look up the link library configuration file more /etc/ld.so.conf| grep /usr/local/lib#If not included, edit this article to add: vi /etc/ld.so.conf/usr/local/lib/usr/local/lib64#Run the configuration command ldconfig
About ffmpeg Introduction:
FFmpeg is an open-source, free, cross-platform video and audio streaming solution that is free software under either the LGPL or GPL license (depending on the component you choose). It provides a complete solution for recording, converting and streaming audio and video. It contains a very advanced audio/video codec library libavcodec, many of which were developed from scratch to ensure high portability and codec quality. Its official website is www.ffmpeg.org
Finally, refer to http://www.example.com for some contents. linux.it.Net.cn/e/Linuxit/2014/0828/3980.html
2. Use ffmpeg command
After the first step, you can use ffmpeg --help to see if the installation is correct, if not, please check whether you forgot to make install
The command to use the conversion is ffmpeg -i 1.amr 2.mp3
converts 1.amr to 2.mp3
Use php to execute linux instructions ffmpeg
Of course, the conversion of files cannot be done by yourself, so we use php to execute linux instructions to process amr files.
Use the exec function to execute
$amr = "./ ".$ vo["voice"];$mp3 = $amr. ".mp3";if(file_exists($mp3) == true){ // exit("no conversion required");}else{ $command = "/usr/local/bin/ffmpeg -i $amr $mp3"; exec($command,$error);}
Take a closer look at the code. I use/usr/local/bin/ffmpeg to execute it, because I can't run ffmpeg directly with php. If your instruction is not in this directory, you can use locate or find to find the directory where ffmpeg is located.
About "PHP how to convert amr audio file to mp3 format" content is introduced here, thank you for reading. If you want to know more about industry-related knowledge, you can pay attention to the industry information channel. Xiaobian will update different knowledge points for you every day.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.