Alex Wulff Alex Wulff - 1 year ago 119
iOS Question

isVideoOrientationSupported always Returns NO AVCaptureConnection

I'm using

to detect faces on iOS, and I'm trying to set the orientation of the video after the user rotates their device. However, it appears that I can't do this as every time I call the getter
on the only AVCaptureConnection that my
has, it always returns false. I've tried the code below in every place imaginable, yet it always returns no. Is there any way to set orientation for my metadata?

AVCaptureConnection *conn = [self.metadataOutput connectionWithMediaType:AVMediaTypeMetadataObject];


if (!conn) {

if ([conn isVideoOrientationSupported]) {

else {
NSLog(@"Not supported");

Answer Source

An Apple Engineer solved this for me over on the Apple Developer Forums. Here's a link. This was their response:

If you want to translate your metadata objects' coordinate space to that of another AVCaptureOutput (such as the AVCaptureVideoDataOutput), use - (AVMetadataObject *)transformedMetadataObjectForMetadataObject:(AVMetadataObject *)metadataObject connection:(AVCaptureConnection *)connection NS_AVAILABLE_IOS(6_0); It's in AVCaptureOutput.h. If you want to translate the coordinates to the coordinate space of your video preview layer, use AVCaptureVideoPreviewLayer.h's - (AVMetadataObject *)transformedMetadataObjectForMetadataObject:(AVMetadataObject *)metadataObject NS_AVAILABLE_IOS(6_0);