2013-10-03 44 views

回答

7

根據頭文件(AVCaptureSession.h)

此屬性已被棄用iOS上,其中最小和最大幀速率調整是 使用 activeVideoMinFrameDuration和activeVideoMaxFrameDuration 屬性只施加在AVCaptureDevice 。

+0

activeVideoMinFrameDuration ISN」爲我工作,我試圖在捕捉開始之前或之後改變它的主動設備,有什麼建議嗎? – avishic

7
在iOS7

使用下列順序我讓它運行在我指定的幀速率(我也有使用activeVideoMinFrameDuration了一些問題,但是這似乎是一個有效的解決方案):

AVCaptureDevice* camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; 
if([camera isTorchModeSupported:AVCaptureTorchModeOn]) { 
    [camera lockForConfiguration:nil]; 
    //configure frame rate 
    [camera setActiveVideoMaxFrameDuration:CMTimeMake(1, samplingFrequency)]; 
    [camera setActiveVideoMinFrameDuration:CMTimeMake(1, samplingFrequency)]; 
    [camera unlockForConfiguration]; 
} 

AVCaptureInput* cameraInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:nil]; 
AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init]; 
dispatch_queue_t captureQueue=dispatch_queue_create("catpureQueue", DISPATCH_QUEUE_SERIAL); 

//setup delegate 
[videoOutput setSampleBufferDelegate:self queue:captureQueue]; 

videoOutput.videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey, 
          nil]; 
[catpureSession setSessionPreset:AVCaptureSessionPresetMedium]; 

if([catpureSession canAddInput:cameraInput]) 
    [catpureSession addInput:cameraInput]; 
if([catpureSession canAddOutput:videoOutput]) 
    [catpureSession addOutput:videoOutput]; 

[catpureSession startRunning]; 

哪裏catpureSession是類的一個對象AVCaptureSessionsamplingFrequency是我的幀速率(設定爲30)

+1

在iOS上,當AVCaptureDevice的activeFormat更改,sessionPreset更改或設備的輸入添加到會話時,文檔指出'activeVideoMinFrameDuration'和'activeMaxFrameDuration'屬性重置爲默認值。因此,在iOS上,您應該在開始運行捕獲會話之前調用「activeVideoMaxFrameDuration」和「activeVideoMinDuration」屬性。 – tumtumtum

相關問題