1

I am using this standard example to show video from camera to iPhone screen. I can see video BUT it is zoomed. When I use standard iPhone camera app I can see more on picture.

I am pretty sure that answer is simple, but it seems my english is not good enough to make a right search phrase.

my app screenshot

-(void)viewDidLoad
{
    [super viewDidLoad];

    cameraPreview = [[UIView alloc] initWithFrame:CGRectMake(0,0,720,1280)] ;
    [self.view addSubview:cameraPreview] ;

    AVCaptureSession *session = [[AVCaptureSession alloc] init];
    session.sessionPreset = AVCaptureSessionPresetHigh;

    CALayer *viewLayer = cameraPreview.layer;
    NSLog(@"viewLayer = %@", viewLayer);

    AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];

    captureVideoPreviewLayer.frame = cameraPreview.bounds;
    [cameraPreview.layer addSublayer:captureVideoPreviewLayer];

    AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];

    NSError *error = nil;
    AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
    if (!input) {
        // Handle the error appropriately.
        NSLog(@"ERROR: trying to open camera: %@", error);
    }
    [session addInput:input];

    [session startRunning];
}
rmaddy
  • 314,917
  • 42
  • 532
  • 579

1 Answers1

0

There are a lot of possible reason, the first one is about the resolution of the frames that you are getting, AVCaptureSessionPresetHighmeans different res on different devices. Once you get the frames they should be shown inside the preview layer.
The AVCaptureVideoPreviewLayer has aspect mode like a UIImageView called -videoGravity.
Size of the frames combined to different videoGravity can change the way the preview layer shows them.

Andrea
  • 26,120
  • 10
  • 85
  • 131
  • Hi @Andrea can you recommend how to capture full screen video on the 5S and other larger devices? Having difficulty ... http://stackoverflow.com/questions/34704032/swift-video-records-at-one-size-but-renders-at-wrong-size/34710892. Thanks! – Crashalot Jan 12 '16 at 01:35