【问题标题】:AVAssetWriter can't create m4a file on iPhone 3GAVAssetWriter 无法在 iPhone 3G 上创建 m4a 文件
【发布时间】:2012-03-28 10:27:32
【问题描述】:

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

【问题讨论】:

    标签: ios aac avassetwriter


    【解决方案1】:

    正如您所说,iPhone 3G 不支持“内置”AAC 编码 (sorry, no direct link, scroll about a page down to table 1-2),因此如果不捆绑您自己的编码器,就无法做到这一点。

    问题在于捆绑 AAC 编码器需要专利许可。如果这是您可以处理的问题,您应该可以为 iPhone 编译 faad2 并使用它。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-07-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-01-06
      • 1970-01-01
      相关资源
      最近更新 更多