我正在尝试使用 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 文件?谢谢