IOS audio format conversion tool Library: ExtAudioConverter,
Some time ago, it was related to iOS audio and needed a function: Converting audio from wav format to mp3 format. This requirement is not very strong, but it is not very easy to implement.
So I wrote an open-source audio format conversion library, which contains all the audio formats supported by iOS/OS X, and also supportsMp3 format(Implemented using lame ). It is modeled on OS Xafconvert
Command parameter settings will be more extensive in the future than afconvert.
The open-source library named ExtAudioConverter is implemented based on ExtAudioFile. Link here: https://github.com/lixing123/ExtAudioConverter
How to use:
ExtAudioConverter* converter = [[ExtAudioConverter alloc] init]; converter.inputFile = @"/your/input/file"; converter.outputFile = @"/your/output/file"; [converter convert];
The Code passes the test on iOS and OS X.
Some optional parameters:
1. Sampling Rate
converter.outputSampleRate = 44100;
converter.outputNumberChannels = 2;
converter.outputBitDepth = BitDepth_16;
converter.outputFileType = kAudioFileWAVEType;
converter.outputFormatID = kAudioFormatLinearPCM;
For instructions on file formats and data formats, here: https://developer.apple.com/library/ios/documentation/MusicAudio/Conceptual/CoreAudioOverview/SupportedAudioFormatsMacOSX/SupportedAudioFormatsMacOSX.html
Simply put, a file format corresponds to one or more data formats. For example, mp3 file format only corresponds to mp3 data Format, and caf (Core Audio format) format corresponds to almost all data formats. Therefore, the default output file format of the tool library is the caf format.
There is no bit rate setting interface yet. Add as needed.
If you need it, you can download it. If you have any questions or suggestions
1. Contact me to comment in this article;
2. Send the Issues to the project;
3. mail to my mailbox: shangwangwanwan@gmail.com
If you have a github account, one Star/Follow encourages me to continue contributing to the open-source community. Thank you!