问题
Am trying to create video from images using AVAssetWriter. Implemented code works fine most of time, but in random moments there is problem with writer
AVAssetWriter *videoWriter;
...
[videoWriter finishWriting];
NSLog(@"videoWriter error %@",videoWriter.error);
Received error is:
Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed"
UserInfo=0x1f839cd0 {NSLocalizedDescription=The operation could not be completed,
NSUnderlyingError=0x1e59efb0 "The operation couldn’t be completed. (OSStatus error -12633.)",
NSLocalizedFailureReason=An unknown error occurred (-12633)}
Writing images:
-(void)writeFrame:(WriteableFrame*)wF
{
if([writerInput isReadyForMoreMediaData])
{
CMTime presentTime = CMTimeMake(wF.frameTime, 1000);
CGImageRef tmpImgRef = [wF.currentImage CGImage];
buffer = [self pixelBufferFromCGImage:tmpImgRef];
if(buffer)
{
[adaptor appendPixelBuffer:buffer withPresentationTime:presentTime];
CVPixelBufferRelease(buffer);
}
}
else
{
NSLog(@"error");
}
}
Is there someone with problem like this?
回答1:
I found the problem, it was putting two frames at the same frame time.
回答2:
Direct from DTS
Error -12633 is a InvalidTimestamp
回答3:
If you give a sampleBuffer to the AVAssetWriter, then destroy the associated AVAssetReader, future AVAssetReaders may try to reuse the sampleBuffer before AVAssetWriter is finished with it. This is in contradiction to the AVAssetWriter documentation in AVAssetWriterInput.h, and as far as I am aware there is no way to be sure AVAssetWriter is finished until you get the callback in finishWritingWithCompletionHandler, but this can result in the OSStatus error -12633.
@method appendSampleBuffer:
The receiver will retain the CMSampleBuffer until it is done with it, and then release it. Do not modify a CMSampleBuffer or its contents after you have passed it to this method.
回答4:
It may also happen if pushed frames is out of order
回答5:
I was getting the same error when the image in my pixel buffer was not of the same width/height dimensions that the input pixel buffer adapter expects based on what you set the sourcePixelBufferAttributes to for(kCVPixelBufferWidthKey, kCVPixelBufferHeightKey). Make sure the pixel buffer has those same dimensions. In my case, my application was sometimes drawing a 1x1 image because I intended to draw a solid color image but I neglected to upscale that single-color pixel to the full size.
来源:https://stackoverflow.com/questions/15071387/avassetwriter-unknown-error