使用 AVFoundation 压缩 iPhone 16 Pro Max 上录制的视频时,音频压缩期间出现问题。当调用AVAssetWriterInputappendSampleBuffer时,writer的状态变为failed,并输出以下错误信息。
一些关键代码:
self.audioSettings = @{
AVFormatIDKey: @(kAudioFormatMPEG4AAC),
AVNumberOfChannelsKey: @2,
AVSampleRateKey: @44100,
AVEncoderBitRateKey: @128000,
};
[self.audioInput requestMediaDataWhenReadyOnQueue:self.inputQueue usingBlock:^ {
while (input.isReadyForMoreMediaData) {
CMSampleBufferRef sampleBuffer = [output copyNextSampleBuffer];
if (sampleBuffer) {
if ([input appendSampleBuffer:sampleBuffer]) {
// Something went wrong here!
}
}
}
}];
错误信息:
Error Domain=AVFoundationErrorDomain Code=-11800 "This operation cannot be completed" UserInfo={
NSLocalizedFailureReason=An unknown error occurred(-12780),
NSLocalizedDescription=This operation cannot be completed,
NSUnderlyingError=0x3023db8a0 {
Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"
}
}
发生了什么以及如何修复它?
请问这个问题最终是如何解决的。