2011-11-17 1 views
0

FireWire 입력에서 캡처하는 Quartz Composer 용 사용자 정의 패치를 만들려고합니다. 장치를 열고 입력을 성공적으로 추가 할 수 있습니다. QTKit 문서에 따라 오디오 입력을 비활성화 할 수도 있습니다. 나는 나의 문제가 출력을 추가하고 있다고 의심한다. 프레임이 실행될 때마다 imageBuffer가 비어있을 때 충돌합니다. 그것은 차원이나 아무것도 없습니다. 설명서에서 표준 captureOutput : didOutputVideoFrame : withSampleBuffer : fromConnection을 사용하고 있습니다.QTCaptureDecompressedVideoOutput with FireWire

[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 (다중화) 입력에는 적합하지 않습니다.

답변

0

mCaptureDecompressedVideoOutput에서 kCVPixelBufferOpenGLCompatibilityKey를 제거하여이 패치가 비디오 및 다중 입력 모두에서 작동하도록했습니다. Quartz Composer 내에서 패치가 완벽하게 작동하는 동안, OpenGL 지원이 필요하지 않은 것으로 보이는 CamTwist 내에서 사용되는 컴포지션에서이 패치를 실행하려고합니다. 바로 지금, 비디오 입력 또는 Muxed 입력이있는 검은 색 화면이 표시되고 이전에는 비디오 입력과 함께 작동합니다. 그래서 CVImageBufferRef를 OpenGL 텍스처로 변환하고 작업 할 수 있는지 알아 보겠습니다.

outputImageProviderFromTextureWithPixelFormat:pixelsWide:pixelsHigh:name:flipped:releaseCallback:releaseContext:colorSpace:shouldColorMatch