1

I am capturing a video in my IOS app using AVFoundation. i am able to record the video and able to playback also.

But my problem is that i am showing the capturing video in a view which is around 200 points height.so i expected the video would be recorded in the same dimensions.but when i playback the video its showing that the whole screen has been recorded.

so i want to know is there any way to record the camera preview which was visible to user only.And any help should be appreciated.

the screenshots: (While Recording) (while playback)

sateesh
  • 505
  • 4
  • 18

1 Answers1

0

You cannot think of video resolution in terms of UIView dimensions (or even screen size, for that matter). The camera is going to record at a certain resolution depending on how you set up the AVCaptureSession. For instance, you can change the video quality by setting the session preset via:

[self.captureSession setSessionPreset:AVCaptureSessionPreset640x480]

(It is already set by default to the highest setting.)

Now, when you play the video back, you do have a bit of control over how it is presented. For instance, if you want to play it in a smaller view (who's layer is of type AVPlayerLayer), you can set the video gravity via:

AVCaptureVideoPreviewLayer *previewLayer = (AVCaptureVideoPreviewLayer*)self.previewView.layer;
[previewLayer setVideoGravity:AVLayerVideoGravityResizeAspect];

And depending on what you pass for the gravity parameter, you will get different results.

Hopefully this helps. Your question is a little unclear as it seems like you want the camera to only record a certain amount of it's input, but you'd have to put your hand over part of the lens to accomplish that ;)

joelg
  • 1,094
  • 9
  • 19
  • thanks joeig for your answer. i got what you are saying.And i want to know is it possible to capture the part of the cameras input.If possible how to do that. – sateesh Aug 21 '14 at 13:12
  • I don't believe that is possible. You might be able to create a composition after you've recorded input, but to tell the camera to ignore a portion of the input... I don't know how you would do that. Can you explain why you want only a portion of the input? – joelg Aug 21 '14 at 13:14
  • Its as per my app design. i can't provide any more information other than that. – sateesh Aug 21 '14 at 13:17
  • Even if you could think of a situation that is analogous, it would help people to know how to address the question. – joelg Aug 21 '14 at 14:23