22kHz の wave ファイルがあり、22kHz の m4a ファイルが必要です。プリセット AVAssetExportPresetAppleM4A を使用した AVAssetExportSession は、私の wav を 44kHZ に自動的に変換します。ExportSession を作成するためにさまざまなプリセットと nil を試しましたが、成功しませんでした。
AVAssetExportSession のカスタム エクスポート プロパティを設定する方法はありますか、それともWAV ファイルを M4A に変換する方法に記載されているようなまったく異なるアプローチが必要ですか? ?
ここに私がこれまでに持っているコードがあります。これは、44kHz ファイルが必要な場合にうまく機能します。
AVURLAsset *wavAsset = [AVURLAsset URLAssetWithURL:[NSURL fileURLWithPath:wavPath] options:optionsDict];
AVMutableComposition *mutableComposition = [AVMutableComposition composition];
[mutableComposition insertTimeRange:CMTimeRangeMake(kCMTimeZero, wavAsset.duration)
ofAsset:wavAsset atTime:kCMTimeZero error:&error];
AVAssetExportSession *exportSession = [[AVAssetExportSession alloc]
initWithAsset:[mutableComposition copy] presetName:AVAssetExportPresetAppleM4A];
exportSession.outputURL = [NSURL fileURLWithPath:m4aPath];
exportSession.outputFileType = AVFileTypeAppleM4A;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
switch (exportSession.status) {
case AVAssetExportSessionStatusCompleted: {
[exportSession release];
completionHandler(nil);
break;
}
case AVAssetExportSessionStatusFailed: {
NSLog(@"There was an error while exporting the file: %@", exportSession.error);
completionHandler(exportSession.error);
break;
}
// ... handle some other cases...
default: {
break;
}
}
}];
私が何かを逃しただけなら素晴らしいでしょう。
前もってありがとう、ドム