0

我正在尝试为 Quartz Composer 创建一个从 FireWire 输入捕获的自定义补丁。我可以打开设备并成功添加输入。我什至根据 QTKit 文档禁用了音频输入。我怀疑我的问题是添加输出(尽管它添加没有错误)。每次框架运行时,它都会在 imageBuffer 为空时崩溃。它没有维度或任何东西。我正在使用文档中的标准 captureOutput:didOutputVideoFrame:withSampleBuffer:fromConnection 。

   [mCaptureDecompressedVideoOutput release];
    mCaptureDecompressedVideoOutput = [[QTCaptureDecompressedVideoOutput alloc] init];
    NSLog(@"allocated mCaptureDecompressedVideoOutput");
    [mCaptureDecompressedVideoOutput setPixelBufferAttributes:
     [NSDictionary dictionaryWithObjectsAndKeys:
      [NSNumber numberWithBool:YES], kCVPixelBufferOpenGLCompatibilityKey,
      [NSNumber numberWithLong:k32ARGBPixelFormat], kCVPixelBufferPixelFormatTypeKey, nil]];


    [mCaptureDecompressedVideoOutput setDelegate:self];
    success = [mCaptureSession addOutput:mCaptureDecompressedVideoOutput error:&error];

    if (!success) {
        NSLog(@"Failed to add output");
            self.outputImage = nil; 
        if (mCaptureSession) {
            [mCaptureSession release];
            mCaptureSession= nil;
        }
        if (mCaptureDeviceInput) {
            [mCaptureDeviceInput release];
            mCaptureDeviceInput= nil;
        }
        if (mCaptureDecompressedVideoOutput) {
            [mCaptureDecompressedVideoOutput release];
            mCaptureDecompressedVideoOutput= nil;
        }
        return YES;
    }

    [mCaptureSession startRunning]; 
        _currentDevice= self.inputDevice;
    }

    CVImageBufferRef imageBuffer = CVBufferRetain(mCurrentImageBuffer);

if (imageBuffer) {
    CVPixelBufferLockBaseAddress(imageBuffer, 0);
    NSLog(@"ColorSpace: %@", CVImageBufferGetColorSpace(imageBuffer));

    id provider= [context outputImageProviderFromBufferWithPixelFormat:QCPlugInPixelFormatARGB8           
                                                            pixelsWide:CVPixelBufferGetWidth(imageBuffer)
                                                            pixelsHigh:CVPixelBufferGetHeight(imageBuffer)
                                                           baseAddress:CVPixelBufferGetBaseAddress(imageBuffer)
                                                           bytesPerRow:CVPixelBufferGetBytesPerRow(imageBuffer)
                                                       releaseCallback:_BufferReleaseCallback
                                                        releaseContext:imageBuffer
                                                            colorSpace:CVImageBufferGetColorSpace(imageBuffer)
                                                      shouldColorMatch:YES];

我可能做错了什么?此代码适用于仅视频输入,但不适用于 FireWire(多路复用)输入。

4

1 回答 1

0

通过从 mCaptureDecompressedVideoOutput 中删除 kCVPixelBufferOpenGLCompatibilityKey,我设法让这个补丁同时处理视频和复用输入。虽然这允许补丁在 Quartz Composer 中完美运行,但我的意图是在 CamTwist 内部使用的合成中运行此补丁,这似乎不需要 OpenGL 支持。现在,它只显示一个带有枯萎视频或多路输入的黑屏,它以前使用视频输入。所以,我要将我的 CVImageBufferRef 转换为 OpenGL 纹理,看看是否可以使用它

outputImageProviderFromTextureWithPixelFormat:pixelsWide:pixelsHigh:name:flipped:releaseCallback:releaseContext:colorSpace:shouldColorMatch
于 2011-11-19T15:02:52.027 回答