根據this document與視頻幀的最大和最小持續時間的屬性和方法:替代已棄用的AVCaptureConnection幀持續時間屬性?
supportsVideoMaxFrameDuration
supportsVideoMinFrameDuration
videoMaxFrameDuration
videoMinFrameDuration
都被廢棄了。有替代品嗎?
根據this document與視頻幀的最大和最小持續時間的屬性和方法:替代已棄用的AVCaptureConnection幀持續時間屬性?
supportsVideoMaxFrameDuration
supportsVideoMinFrameDuration
videoMaxFrameDuration
videoMinFrameDuration
都被廢棄了。有替代品嗎?
根據頭文件(AVCaptureSession.h)
此屬性已被棄用iOS上,其中最小和最大幀速率調整是 使用 activeVideoMinFrameDuration和activeVideoMaxFrameDuration 屬性只施加在AVCaptureDevice 。
使用下列順序我讓它運行在我指定的幀速率(我也有使用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是類的一個對象AVCaptureSession和samplingFrequency是我的幀速率(設定爲30)
在iOS上,當AVCaptureDevice的activeFormat更改,sessionPreset更改或設備的輸入添加到會話時,文檔指出'activeVideoMinFrameDuration'和'activeMaxFrameDuration'屬性重置爲默認值。因此,在iOS上,您應該在開始運行捕獲會話之前調用「activeVideoMaxFrameDuration」和「activeVideoMinDuration」屬性。 – tumtumtum
activeVideoMinFrameDuration ISN」爲我工作,我試圖在捕捉開始之前或之後改變它的主動設備,有什麼建議嗎? – avishic