アプリに音声を録音して保存するコントロールがあります。AVMutableCompositionを使用して古い録音に新しい録音を追加し、ユーザーが保存する準備ができたら、AVAssetExportSessionを使用してすべてを新しいファイルに書き込もうとしています。これを行うと、エラーは発生せず、ファイルが書き込まれます。ただし、そのファイルは再生できず、完了ブロックが呼び出されることはありません。誰かがこれを引き起こしている可能性があるものを知っていますか?
コードは次のとおりです。
AVAssetExportSession *exportSession = [AVAssetExportSession exportSessionWithAsset:composition presetName:AVAssetExportPresetAppleM4A];
exportSession.outputURL = URL;
exportSession.outputFileType = AVFileTypeAppleM4A;
exportSession.shouldOptimizeForNetworkUse = YES;
[exportSession exportAsynchronouslyWithCompletionHandler:^{
NSLog(@"Export Complete");
}];
変数composition
は、1つ以上のAVURLAssets(以前または現在の記録)を追加したAVMutableCompositionです。
アップデート
これが役立つかどうかはわかりませんが、AVAudioRecorderを使用してオーディオを録音しており、次の設定を使用しています。
[recordSetting setObject:[NSNumber numberWithInt:kAudioFormatMPEG4AAC] forKey:AVFormatIDKey];
[recordSetting setObject:[NSNumber numberWithFloat:44100.0] forKey: AVSampleRateKey];
[recordSetting setObject:[NSNumber numberWithInt:1] forKey:AVNumberOfChannelsKey];
[recordSetting setObject:[NSNumber numberWithInt:64000] forKey:AVEncoderBitRateKey];
[recordSetting setObject:[NSNumber numberWithInt: AVAudioQualityMedium] forKey: AVEncoderAudioQualityKey];
更新2
記録されたファイルから生成されたAVURLAssetを使用して同じコードを試しましたが、基本的にAVMutableCompositionを切り取って、問題がないことを確認しました。それはまだ機能していません。
これに関する助けをいただければ幸いです。