ios – AVAssetWriterInputPixelBufferAdaptor pixelBufferPool在一段时间后变为NULL

ios – AVAssetWriterInputPixelBufferAdaptor pixelBufferPool在一段时间后变为NULL,第1张

概述我在AVAssetWriterInputPixelBufferAdaptor中使用pixelBufferPool来创建像素缓冲区以与append方法一起使用.创建4个缓冲区后,pixelBufferPool属性变为NULL; 我设置了我的编写器,输入和适配器,如下所示: - (BOOL) setupRecorder { NSError *error = nil; if([[NSFi 我在AVAssetWriterinputPixelBufferAdaptor中使用pixelBufferPool来创建像素缓冲区以与append方法一起使用.创建4个缓冲区后,pixelBufferPool属性变为NulL;

我设置了我的编写器,输入和适配器,如下所示:

- (BOol) setupRecorder {    NSError *error = nil;    if([[NSfileManager defaultManager] fileExistsAtPath:[[self tempfileURL] path]])        [[NSfileManager defaultManager] removeItemAtURL:[self tempfileURL] error:&error];    assetWriter = [[AVAssetWriter alloc] initWithURL: [self tempfileURL]                                             fileType:AVfileTypeQuickTimeMovIE                                               error:&error];     if (error) {        NSLog(@"Error creating asset writer: %@",error);        [assetWriter release];        return NO;    }    // writer    NSDictionary *vIDeoSettings = [NSDictionary dictionaryWithObjectsAndKeys:                                   AVVIDeoCodecH264,AVVIDeoCodecKey,[NSNumber numberWithInt:vIDeoWIDth],AVVIDeoWIDthKey,[NSNumber numberWithInt:vIDeoHeight],AVVIDeoHeightKey,nil];    assetWriterinput = [AVAssetWriterinput assetWriterinputWithMediaType:AVMediaTypeVIDeo                                                       outputSettings:vIDeoSettings];    NSDictionary *bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:                                       [NSNumber numberWithInt:kCVPixelFormatType_32BGRA],kCVPixelBufferPixelFormatTypeKey,nil];    adaptor = [[AVAssetWriterinputPixelBufferAdaptor alloc] initWithAssetWriterinput:assetWriterinput sourcePixelBufferAttributes:bufferAttributes];      [adaptor retain];    assetWriterinput.expectsMediaDataInRealTime = YES;    [assetWriter addinput:assetWriterinput];    return YES;}

我用这个分配像素缓冲区:

- (CVPixelBufferRef) createPixelBufferRef {    CVPixelBufferPoolRef pixelBufferPool = adaptor.pixelBufferPool;    CVPixelBufferRef pixelBuffer = NulL;    CVReturn cvReturn = CVPixelBufferPoolCreatePixelBuffer(NulL,pixelBufferPool,&pixelBuffer);    if(cvReturn != kCVReturnSuccess)        NSLog(@"CVPixelBuffePoolCreatePixelBuffer: %d",cvReturn);    bufferCreatedCount++;    return pixelBuffer;}

当我完成将像素缓冲区传递给appendPixelBuffer时,我使用CVPixelBufferRelease释放像素缓冲区.在此之前的任何时候,我都不会调用markAsFinished,endSessionAtSourceTime或finishWriting.此外,适配器本身不会为NulL.

我读过的大多数帖子都谈到了由于配置错误配置而导致池从一开始就缺席,但是我的存在,但只是很短的时间.其他人看到过这种行为?

解决方法 在像素缓冲适配器错误的情况下可能会发生这种情况.像素缓冲适配器可能会因错误推出的帧或具有相同的显示时间而进入错误状态. 总结

以上是内存溢出为你收集整理的ios – AVAssetWriterInputPixelBufferAdaptor pixelBufferPool在一段时间后变为NULL全部内容,希望文章能够帮你解决ios – AVAssetWriterInputPixelBufferAdaptor pixelBufferPool在一段时间后变为NULL所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1104945.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存