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++ #CentOS2. Compile the required source code package
#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和已安装的扩展,则运行成功。 ldconfig3. How to use
ffmpeg -i 1.mp3 -ac 1 -ar 8000 1.amr #MP3转换AMR ffmpeg -i 1.amr 1.mp3 #AMR转换MP3Appendix:
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); }Look at the code carefully. I use /usr/local/bin/ffmpeg to execute it, because I cannot directly run the ffmpeg command using PHP. If your command is not in this directory, you can use locate or find to find the directory where ffmpeg is located Recommended study: "
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!

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct


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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 English version
Recommended: Win version, supports code prompts!

WebStorm Mac version
Useful JavaScript development tools

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

SublimeText3 Linux new version
SublimeText3 Linux latest version