0
我有一個videoInput設備列表。 首先,我添加了錄音的默認輸入設備,設置壓縮,輸出和所需的所有東西。之後,我試圖改變輸入設備,但不知何故,視圖停止工作,它只顯示黑屏。當我不錄製時,我試圖改變,只在視圖中顯示輸入。 下面是修改代碼:更改視頻輸入設備QTkit
-(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];
}