For this article I refer to :iOS LAME
1. Cross-compile LAME
1.1 introduction of LAME
LAME is one of the best MP3 encoders in the industry. The LAME library is the most popular encoder for transcoding MP3 audio files. At 320Kbit/s, the quality of the audio encoded by LAME is almost as good as that of CD, while keeping the size of the entire audio file very small. So if you want to encode MP3 files on mobile platforms, using LAME is the only option.
LAME download address
Note: The advanced Audio and Video Development book uses version 3.99.5,
1.2 Enable LAME on iOS via scripting
/configure \ --disable-shared \ --disable-frontend \ --host=arm-apple-darwin \ ## --prefix="/Users/ Pangrifu /Desktop/ programming knowledge /lame/thin/arm64" \ CC=" xcrun-sdk iphoneOS clang-arch arm64" \ CFLAGS="-arch arm64-fembed-bitcode -miphoneos-version-min=7.0" \ LDFLAGS="-arch arm64-fembed-bitcode -miphoneos-version-min=7.0" make clean make -j8 make installCopy the code
Configure: this command is required for GNU standard software package distribution. Therefore, makefile is generated by configure, and the entire library is compiled and installed by make and makeinstall. You can run the conf igure -h command to view the conf igure help documentation for the optional configuration items of LAME as follows:
–prefix: Which directory to put the compiled libraries in
–host: specifies the most important running console
CC: Specifies the path to the cross-tool build chain
CFLAGS: Specifies the parameters to take with you at compile time
1.3LAME cross-compile the actual
1.3.1 Step1 Download LAME library file
LAME download address
1.3.2 Step2 Write a script file
For details on how to create a script file, see the previous article: Creating a.sh script file on Mac
1.3.3 Step3 Directory structure
1.3.4 step4 generate the. A file
In terminal, CD to lame-3.100
CD /Users/ Pangrifu /Desktop/ Programming knowledge/video advanced code /lame/lame-3.100Copy the code
And then execute the commandsudo .. /build_armv7.sh
, prompting you to enter the password, and then you can enter the password. At this time, the following files are in the directory:
Using the same steps, you can compile the arm64 version and then use lipo-create to merge the static libraries
Note that the arm64 does not have a V, I wrote the script, thanks to a V, resulting in many errors, check for a long time to find the problem.
throughlip -creat
The command merges the arm64 and armv7. A files
Lipo-create./arm64/lib/libmp3lame.a(1th.a file path)./armv7/lib/libmp3lame.a(2th.a file path) -output libmp3lame.a(output file)Copy the code
After the merge, use file libmp3lame.a to verify that the compilation is successful if the following output is printed:
libmp3lame.a: Mach-O universal binary with 2 architectures: [arm_v7:current ar archive random library] [arm64]
libmp3lame.a (for architecture armv7): current ar archive random library
libmp3lame.a (for architecture arm64): current ar archive random library
Copy the code
2.FDK_AAC cross-compilation
2.1 FDK_AAC profile
Fraunhofer is the core developer of the AAC audio specification.
2.2FDK_ACC Compiles the script
Script download address
ios build fdk-aac
Note that file paths are not named in Chinese