Skip to content

Instantly share code, notes, and snippets.

@sgss
Last active December 12, 2015 02:58
Show Gist options
  • Save sgss/4702927 to your computer and use it in GitHub Desktop.
Save sgss/4702927 to your computer and use it in GitHub Desktop.
// Derive dimensions of the capture device input.
AVCaptureInputPort *captureDeviceInputPort = nil;
for (AVCaptureInputPort *port in [captureDeviceInput ports]) {
if ([[port mediaType] isEqualToString:AVMediaTypeVideo]) {
captureDeviceInputPort = port;
break;
}
}
if (!captureDeviceInputPort) {
NSLog(@"Capture device input port of video media type was "
@"unexpectedly not found.");
NSLog(@"Skipping.");
return;
}
CMFormatDescriptionRef formatDescription =
[captureDeviceInputPort formatDescription];
CMVideoDimensions videoDimensions =
CMVideoFormatDescriptionGetDimensions(formatDescription);
[self willChangeValueForKey:@"inputSize"];
inputSize = CGSizeMake(
(CGFloat)videoDimensions.width, (CGFloat)videoDimensions.height);
[self didChangeValueForKey:@"inputSize"];
NSLog(@"Derived device input size: %@", NSStringFromCGSize(inputSize));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment