gpt4 book ai didi

cocoa-touch - iOS8视频尺寸,CMVideoDimensions返回0,0

转载 作者:行者123 更新时间:2023-12-04 03:06:22 27 4
gpt4 key购买 nike

在 iOS8 中返回的维度是 0,0

CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);

这是在 iOS7 上工作的,所以如何知道支持的视频尺寸,因为我需要知道视频宽高比

最佳答案

您需要等待AVCaptureInputPortFormatDescriptionDidChangeNotification

- (void)avCaptureInputPortFormatDescriptionDidChangeNotification:(NSNotification *)notification {

AVCaptureInput *input = [self.recorder.captureSession.inputs objectAtIndex:0];
AVCaptureInputPort *port = [input.ports objectAtIndex:0];
CMFormatDescriptionRef formatDescription = port.formatDescription;
if (formatDescription) {
CMVideoDimensions dimensions = CMVideoFormatDescriptionGetDimensions(formatDescription);
if ((dimensions.width == 0) || (dimensions.height == 0)) {
return;
}
CGFloat aspect = (CGFloat)dimensions.width / (CGFloat)dimensions.height;

if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) {
// since iOS8 the aspect ratio is inverted
// remove this check if iOS7 will not be supported
aspect = 1.f / aspect;
}

}

}

关于cocoa-touch - iOS8视频尺寸,CMVideoDimensions返回0,0,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25902122/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com