简体   繁体   English

AVAssetWriter未知错误

[英]AVAssetWriter unknown error

Am trying to create video from images using AVAssetWriter . 我试图使用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? 有人有这样的问题吗?

我发现了问题,它在相同的帧时间放置了两个帧。

Direct from DTS 直接来自DTS

Error -12633 is a InvalidTimestamp 错误-12633是InvalidTimestamp

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. 如果您将一个sampleBufferAVAssetWriter ,然后销毁关联的AVAssetReader ,未来的AVAssetReaders可能会尝试在AVAssetWriter完成之前重用sampleBuffer 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. 这是矛盾的。 AVAssetWriter在文档AVAssetWriterInput.h ,而据我所知是没有办法,以确保AVAssetWriter ,直到你在回调结束finishWritingWithCompletionHandler ,但是这会导致OSStatus错误-12633。

@method appendSampleBuffer: @method appendSampleBuffer:

The receiver will retain the CMSampleBuffer until it is done with it, and then release it. 接收器将保留CMSampleBuffer,直到完成它,然后释放它。 Do not modify a CMSampleBuffer or its contents after you have passed it to this method. 将CMSampleBuffer或其内容传递给此方法后,请勿修改它。

如果推送的帧出现故障,也可能发生这种情况

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). 当我的像素缓冲区中的图像与输入像素缓冲区适配器所期望的宽度/高度尺寸不同时,基于您为sourcePixelBufferAttributes设置的内容(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. 在我的情况下,我的应用程序有时会绘制1x1图像,因为我打算绘制纯色图像,但我忽略了将单色像素升级到完整尺寸。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM