objective-cvideo-captureqtkit

Change video input device QTkit


I have a list of videoInput devices. First I add the default input device for recording set up the compression, the output and everythin needed. After that I'm trying to change the input device, but somehow, the view stop working and it shows only black screen. I'm trying to change when I'm not recording, only showing the input in a view. Here is the code for changing:

-(void) changeVideoInput:(QTCaptureDevice *)videoDevice{

    BOOL success = NO;
    NSError *error;

    [mCaptureSession stopRunning];
        [mCaptureSession removeInput:mCaptureVideoDeviceInput]; //current input
        [[mCaptureVideoDeviceInput device] close];

        success = [videoDevice open:&error];

        mCaptureVideoDeviceInput2 = [[QTCaptureDeviceInput alloc] initWithDevice:videoDevice]; //new input

        success = [mCaptureSession addInput:mCaptureVideoDeviceInput2 error:&error];

    [mCaptureSession startRunning];    
}

Solution

  • Finally I figured out, that the code is working. The problem causes the opening of the default video device (It's name is: "Blackmagic"). Do not open that device. It is a universal device.