How to convert amr to mp3 in php
How to convert amr to mp3 in php: 1. Install ffmpeg on the server; 2. Use the "ffmpeg -i" command to convert amr to mp3 format; 3. Use the HTML5 audio tag to play on the web page mp3 files will do.
The operating environment of this tutorial: Windows 10 system, PHP version 8.1, DELL G3 computer
How to convert amr to mp3 with php ?
PHP Convert amr audio files to mp3 format
- ## Let’s talk about the overall idea
1. Install ffmpeg on the server, taking cenos as an example
Reference here: http://my.oschina.NET/ethan09/blog/372435It should be noted that in the following method, the installation of amrnb and amrwb into the make link will Requesting a URL of 3gp is generally not available. You can use crtl c to cancel its process, and the format can be converted if these two are not needed.
You must be in the Linux environment when receiving the request To convert amr to mp3, you can directly use the exe method encapsulated in a third-party jar package under Windows, but Linux is not supported. After crawling the Internet, it said that it can be achieved by using ffmpeg plus the amr plug-in. I tried it according to the tutorial:1. First install the system compilation environment
yum install -y automake autoconf libtool gcc gcc-c++ #CentOS
#yasm:汇编器,新版本的ffmpeg增加了汇编代码 wget http://www.tortall.net/projects/yasm/releases/yasm-1.3.0.tar.gz tar -xzvf yasm-1.3.0.tar.gz cd yasm-1.3.0 ./configure make make install #lame:Mp3音频解码 wget http://jaist.dl.sourceforge.net/project/lame/lame/3.99/lame-3.99.5.tar.gz tar -xzvf lame-3.99.5.tar.gz cd lame-3.99.5 ./configure make make install #amr支持 wget http://downloads.sourceforge.net/project/opencore-amr/opencore-amr/opencore-amr-0.1.3.tar.gz tar -xzvf opencore-amr-0.1.3.tar.gz cd opencore-amr-0.1.3 ./configure make make install #amrnb支持 wget http://www.penguin.cz/~utx/ftp/amr/amrnb-11.0.0.0.tar.bz2 tar -xjvf amrnb-11.0.0.0.tar.bz2 cd amrnb-11.0.0.0 ./configure make make install #amrwb支持 wget http://www.penguin.cz/~utx/ftp/amr/amrwb-11.0.0.0.tar.bz2 tar -xjvf amrwb-11.0.0.0.tar.bz2 cd amrwb-11.0.0.0 ./configure make make install #ffmpeg wget http://ffmpeg.org/releases/ffmpeg-2.5.3.tar.bz2 tar -xjvf ffmpeg-2.5.3.tar.bz2 cd ffmpeg-2.5.3 ./configure --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-version3 --enable-shared make make install #加载配置 #最后写入config后,终端运行ffmpeg命令,出现success和已安装的扩展,则运行成功。 ldconfig
ffmpeg -i 1.mp3 -ac 1 -ar 8000 1.amr #MP3转换AMR ffmpeg -i 1.amr 1.mp3 #AMR转换MP3
Appendix 1. The default installation directory of ffmpeg is "/usr/local/lib". In some 64-bit systems, the software directory is "/usr/lib64". ## may occur during the compilation process. #"ffmpeg: error while loading shared libraries: libmp3lame.so.0: cannot open shared object file: No such file or directory" and other similar errors, the solution is to create a soft link:
# ln -s /usr/ local/lib/libmp3lame.so.0.0.0 /usr/lib64/libmp3lame.so.0
Appendix 2. If the following prompt appears: ffmpeg: error while loading shared libraries: libavdevice.so.54: cannot open shared object file: No such file or directory
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 (0x00002ab7c0d9a000) #如果类似于上面的输出内容,查找以上类库,会发现全部在/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 #查看链接库配置文件 more /etc/ld.so.conf | grep /usr/local/lib #如果不包含的话,需要编辑此文添加: vi /etc/ld.so.conf /usr/local/lib /usr/local/lib64 #运行配置命令 ldconfig
About ffmpeg:
FFmpeg is an open source free cross-platform The platform's video and audio streaming solution is free software and licensed under the LGPL or GPL (depending on which component you choose). It provides a complete solution for recording, converting and streaming audio and video. It contains the very advanced audio/video codec library libavcodec. In order to ensure high portability and codec quality, many codecs in libavcodec were developed from scratch. Its official website is: http://www.ffmpeg.org
Finally, please refer to http://linux.it.Net.cn/e/Linuxit/2014/0828/3980.html## for part of the content.
#2. Use the ffmpeg command
After completing the first step, you can use ffmpeg --help to see if it is installed correctly. If not, please check if it is installed correctly. Forgot to use make install
The conversion command is ffmpeg -i 1.amr 2.mp3 will convert 1.amr to 2.mp3三, use php to execute linux instructions ffmpeg
Of course, you cannot convert files by running linux instructions in the server, 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('无需转换'); }else{ $command = "/usr/local/bin/ffmpeg -i $amr $mp3"; exec($command,$error); }
PHP Video Tutorial
"The above is the detailed content of How to convert amr to mp3 in php. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











PHP is a scripting language widely used on the server side, especially suitable for web development. 1.PHP can embed HTML, process HTTP requests and responses, and supports a variety of databases. 2.PHP is used to generate dynamic web content, process form data, access databases, etc., with strong community support and open source resources. 3. PHP is an interpreted language, and the execution process includes lexical analysis, grammatical analysis, compilation and execution. 4.PHP can be combined with MySQL for advanced applications such as user registration systems. 5. When debugging PHP, you can use functions such as error_reporting() and var_dump(). 6. Optimize PHP code to use caching mechanisms, optimize database queries and use built-in functions. 7

PHP and Python each have their own advantages, and the choice should be based on project requirements. 1.PHP is suitable for web development, with simple syntax and high execution efficiency. 2. Python is suitable for data science and machine learning, with concise syntax and rich libraries.

PHP and Python each have their own advantages, and choose according to project requirements. 1.PHP is suitable for web development, especially for rapid development and maintenance of websites. 2. Python is suitable for data science, machine learning and artificial intelligence, with concise syntax and suitable for beginners.

PHP is widely used in e-commerce, content management systems and API development. 1) E-commerce: used for shopping cart function and payment processing. 2) Content management system: used for dynamic content generation and user management. 3) API development: used for RESTful API development and API security. Through performance optimization and best practices, the efficiency and maintainability of PHP applications are improved.

PHP is still dynamic and still occupies an important position in the field of modern programming. 1) PHP's simplicity and powerful community support make it widely used in web development; 2) Its flexibility and stability make it outstanding in handling web forms, database operations and file processing; 3) PHP is constantly evolving and optimizing, suitable for beginners and experienced developers.

PHP is mainly procedural programming, but also supports object-oriented programming (OOP); Python supports a variety of paradigms, including OOP, functional and procedural programming. PHP is suitable for web development, and Python is suitable for a variety of applications such as data analysis and machine learning.

PHP is suitable for web development, especially in rapid development and processing dynamic content, but is not good at data science and enterprise-level applications. Compared with Python, PHP has more advantages in web development, but is not as good as Python in the field of data science; compared with Java, PHP performs worse in enterprise-level applications, but is more flexible in web development; compared with JavaScript, PHP is more concise in back-end development, but is not as good as JavaScript in front-end development.

PHP and Python have their own advantages and disadvantages, and the choice depends on project needs and personal preferences. 1.PHP is suitable for rapid development and maintenance of large-scale web applications. 2. Python dominates the field of data science and machine learning.
