我正在尝试为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 (多路复用)输入。
发布于 2011-11-19 23:02:52
通过从mCaptureDecompressedVideoOutput中删除kCVPixelBufferOpenGLCompatibilityKey,我设法让这个补丁同时支持视频和多路复用输入。虽然这使得补丁可以在Quartz Composer中完美地工作,但我的目的是在CamTwist内部使用的组合中运行这个补丁,它似乎不需要OpenGL支持。现在,它只显示一个黑屏,带有wither或Muxed输入,就像它以前使用视频输入一样。因此,我要将我的CVImageBufferRef转换为OpenGL纹理,看看是否可以使用它
outputImageProviderFromTextureWithPixelFormat:pixelsWide:pixelsHigh:name:flipped:releaseCallback:releaseContext:colorSpace:shouldColorMatchhttps://stackoverflow.com/questions/8162003
复制相似问题