我有一个 videoInput 设备列表。首先,我添加了用于录制的默认输入设备,设置了压缩、输出和所需的一切。之后我试图更改输入设备,但不知何故,视图停止工作,它只显示黑屏。我在不录制时尝试更改,仅在视图中显示输入。这是更改的代码:
-(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];
}