我正在尝试使用AVAssetWriter来创建m4a文件。它适用于任何不包括iPhone 3G的设备。有人说,3G问题不支持AAC编码。这是真的吗? if([assetWriter canAddInput:assetWriterInput])返回NO。
AVAssetWriter *assetWriter = [AVAssetWriter assetWriterWithURL:exportURL
fileType:AVFileTypeAppleM4A
error:&assetError];
if (assetError) {
NSLog (@"error: %@", assetError);
return;
}
AudioChannelLayout channelLayout;
memset(&channelLayout, 0, sizeof(AudioChannelLayout));
channelLayout.mChannelBitmap = 0;
channelLayout.mNumberChannelDescriptions = 0;
channelLayout.mChannelLayoutTag = kAudioChannelLayoutTag_Stereo;
NSDictionary *outputSettings = [NSDictionary dictionaryWithObjectsAndKeys:
[ NSNumber numberWithInt: kAudioFormatMPEG4AAC], AVFormatIDKey,
[ NSNumber numberWithInt: 2], AVNumberOfChannelsKey,
[ NSNumber numberWithFloat: 44100.0], AVSampleRateKey,
[ NSData dataWithBytes: &channelLayout length:sizeof( AudioChannelLayout ) ], AVChannelLayoutKey,
[ NSNumber numberWithInt: 192000], AVEncoderBitRateKey,nil];
AVAssetWriterInput *assetWriterInput = [AVAssetWriterInput assetWriterInputWithMediaType:AVMediaTypeAudio
outputSettings:outputSettings];
if ([assetWriter canAddInput:assetWriterInput]) {
[assetWriter addInput:assetWriterInput];
}
有谁知道,如何在iPhone 3G上创建m4a文件? 感谢
答案 0 :(得分:0)
正如您所说,iPhone 3G不支持AAC(sorry, no direct link, scroll about a page down to table 1-2)的“内置”编码,因此如果不捆绑您自己的编码器,就无法进行此操作。
问题是捆绑AAC编码器需要专利许可。如果这是你可以处理的事情,你应该能够为iPhone编译faad2并使用它。