小编kwz*_*kwz的帖子

AVAssetReaderTrackOutput在copyNextSampleBuffer上挂起

我遇到了这个问题AVAssetWritter.有时我的视频编写会话就会挂起.检查当前在我的设备上运行的线程后,我发现整个视频处理正在等待copyNextSampleBuffer返回.我不知道是什么原因导致了这个问题.有没有人成功克服了这个问题?

下面是从乐器捕获的线程转储.它结束了mach_msg_trap. 线程堆栈

视频处理循环

while ([self.assetWriterVideoInput isReadyForMoreMediaData] && !(*completedOrFailed) && !self.cancelled)
    {
        @autoreleasepool {


            CMSampleBufferRef sampleBuffer = [self.assetReaderVideoOutput copyNextSampleBuffer];



            CVPixelBufferRef pixelBuffer = CMSampleBufferGetImageBuffer(sampleBuffer);
            CVPixelBufferRef croppedBuffer = NULL;
            NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
                                     [NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,
                                     [NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey, nil];
            CVPixelBufferCreate(kCFAllocatorDefault, self.outputSize.width, self.outputSize.height, CVPixelBufferGetPixelFormatType(pixelBuffer), (__bridge CFDictionaryRef) options, &croppedBuffer);
            CIImage *img = [[CIImage alloc] initWithCVPixelBuffer:pixelBuffer];

            // img processing


            [self.context render:img toCVPixelBuffer:croppedBuffer];


            if (sampleBuffer != NULL)
            {

                BOOL success = [self.avPixelAdaptor appendPixelBuffer:croppedBuffer withPresentationTime:sampleTime];

                CFRelease(sampleBuffer);
                sampleBuffer = NULL;
                *completedOrFailed …
Run Code Online (Sandbox Code Playgroud)

avfoundation ios

12
推荐指数
1
解决办法
562
查看次数

标签 统计

avfoundation ×1

ios ×1