Linux compile ffmpeg and convert MP3 to AMR
AMR format is a popular audio file format on smartphones, such as MP3 format, but the file is smaller than MP3, so it is widely used in mobile internet projects. At the end of last year to assist Lenovo Research Institute to develop a pre-installed product process needs to use the MP3 format and AMR format of mutual conversion, the server environment is CentOS 6.0, the process is as follows.
1. First install the system base environment
RHEL & CentOS Series: Yum install-y automake autoconf libtool gcc gcc-c++
Debian & Ubuntu Series: Apt-get install Automake autoconf libtool gcc gcc-c++
2. Download the latest FFmpeg source package
FFmpeg official: http://ffmpeg.org/download.html.
General direct use of the latest version, after the download is done, unzip, into the source folder, run "./configure--help" View Help, here is mainly to confirm the need to install the extension, some extensions are already open by default, and some need to download the extension source package separately to compile. For my needs, for example, you need to compile yasm, lame, Oencore AMR, AMRNB, and AMRWB separately, where lame is the MP3 decoder.
3. Compile the required source code package
Download the five source code packages from each official address, to ensure compatibility with the latest version of FFmpeg, be sure to also download the latest version of the Code:
yasm: http://yasm.tortall.net/Download.html
lame: http://lame.sourceforge.net/download.php
oencore AMR: Http://sourceforge.net/projects/opencore-amr
Amrnb & AMRWB: Http://www.penguin.cz/~utx/amr
Unzip and compile each of the above source packages, and use the "./configure && make && make install" button directly.
4. Compiling FFMPEF
Go back to the FFmpeg source directory, open the desired extension and compile the ffmpeg:
./configure--enable-libmp3lame--enable-libopencore-amrnb--ENABLE-LIBOPENCORE-AMRWB--enable-version3-- Enable-shared
Make && make install
Ldconfig
After the last write to config, the terminal runs the FFmpeg command, the success and installed extensions appear, and the run succeeds.
5. Issues that may be encountered
FFmpeg default installation directory is "/usr/local/lib", some 64-bit systems under the software directory is "/usr/lib64", the compilation process may appear "ffmpeg:error while loading shared libraries: Libmp3lame.so.0:cannot open Shared object file:no such file or directory "Similar error, the solution is to establish a soft link or move the library files to the appropriate directory:
Ln-s/usr/local/lib/libmp3lame.so.0.0.0/usr/lib64/libmp3lame.so.0
mv/usr/local/lib/libmp3lame.so.0.0.0/usr/lib64/libmp3lame.so.0
6. How to use
MP3 conversion amr:ffmpeg-i 1.mp3-ac 1-ar 8000 1.amr
AMR Conversion Mp3:ffmpeg-i 1.amr 1.mp3
Other requirements use method reference Help, where-I means input, AC and AR represent audio bitrate and hertz these concepts, please consult Client Development engineer before use.
Currently can be summarized only so much, if there is a problem, please ask questions. Before I compile a full source package and automatically compile the installed shell script:
#!/bin/shEcho"--------------------------"Echo"Start Installing ..."Echo"--------------------------"Echo"--------------------------"Echo"0. Tar Packages ..."Echo"--------------------------"For IIn *.tar.gz;Do TAR-XZVF"$i";DoneFor IIn *.tar.bz2;Do TAR-XJVF"$i";DoneEcho"--------------------------"Echo"1. Install yasm ..."Echo"--------------------------"CD yasm-1.2.0./configure && make && make installCd..Echo"--------------------------"Echo"2. Install lame ..."Echo"--------------------------"CD lame-3.99.4./configure && make && make installCd..Echo"--------------------------"Echo"3. Install oencore AMR ..."Echo"--------------------------"CD opencore-amr-0.1.3./configure && make && make installCd..Echo"--------------------------"Echo"4. Install amrnb ..."Echo"--------------------------"CD amrnb-10.0.0.0./configure && make && make installCd..Echo"--------------------------"Echo"5. Install AMRWB ..."Echo"--------------------------"CD amrwb-10.0.0.0./configure && make && make installCd..Echo"--------------------------"Echo"Finnal. Install FFMpeg ... "Echo"--------------------------"CD ffmpeg-0.10./configure--enable-libmp3lame--enable-libopencore-amrnb--ENABLE-LIBOPENCORE-AMRWB-- Enable-version3--enable-sharedmake && Make InstallldconfigCD.. echo " --------------------------"echo " FFMpeg Install Successful"echo "Example:: Ffmpeg-i 1.mp3-ac 1-ar 8000 1.amr "echo" Enjoy it ... "echo "--------------------------"
Linux compiler FFmpeg