如何将(aiff)文件转换为在Windows OS(.asf,.asx,.avi,.wav,.wax,.wma,.wm,



我正在做一个iPhone项目,想保存mp3文件而不是car,我写了这段代码来将记录文件保存在.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 格式保存! 它是否在 Objective C 中可用,或者有任何第三方代码可以做到这一点,我在 AudioToolbox.framework 中看到该方法:

OSStatus AudioConverterConvertBuffer (
AudioConverterRef  inAudioConverter,
UInt32             inInputDataSize,
const void         *inInputData,
UInt32             *ioOutputDataSize,
void               *outOutputData
);

欢迎任何帮助,谢谢。

有一个开源项目蹩脚。挑战在于让它适用于iPhone。 这将为 ios 的交叉编译提供方向。

另请注意,它是GPL。

最新更新