我正在开发一个 iPhone 项目,并且想要保存 mp3 文件而不是汽车,我编写了这段代码以将记录文件保存在 .caf 扩展名中:
NSMutableDictionary* recordSetting = [[NSMutableDictionary alloc] init];
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatAppleIMA4] forKey:AVFormatIDKey];
[recordSetting setValue:[NSNumber numberWithFloat:44100.0] forKey:AVSampleRateKey];
[recordSetting setValue:[NSNumber numberWithInt: 2] forKey:AVNumberOfChannelsKey];
NSString *recorderFilePath =[NSString stringWithFormat:@"%@/%@.caf", DOCUMENTS_FOLDER,fileName];
我试过这个:
[recordSetting setValue :[NSNumber numberWithInt:kAudioFormatMPEGLayer3] forKey:AVFormatIDKey];
NSString *recorderFilePath =[NSString stringWithFormat:@"%@/%@.mp3", DOCUMENTS_FOLDER,fileName];
但它没有保存为 mp3 格式!它是在目标 c 中可用还是有任何第三方代码可以实现,我在 AudioToolbox.framework 中看到了该方法:
OSStatus AudioConverterConvertBuffer (
AudioConverterRef inAudioConverter,
UInt32 inInputDataSize,
const void *inInputData,
UInt32 *ioOutputDataSize,
void *outOutputData
);
欢迎任何帮助,谢谢。