【发布时间】:2013-05-20 13:12:57
【问题描述】:
在我的应用程序中,我使用AVCaptureSession 记录video。
录制完成后,我得到的视频大小为 360 X 480。
我设置的记录层大小是320 X 568。
我错过了一些东西,我尝试了但没有找到。
谁能指导我在哪里更改以获取video 大小为320 X 568 的录音
这是我的代码,
初始化
AVCaptureDevice* device = nil;
AVCaptureDeviceInput *captureInput = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil];
AVCaptureVideoDataOutput *captureOutput = [[AVCaptureVideoDataOutput alloc] init];
captureOutput.alwaysDiscardsLateVideoFrames = YES;
dispatch_queue_t queue;
queue = dispatch_queue_create("cameraQueue", NULL);
[captureOutput setSampleBufferDelegate:self queue:queue];
dispatch_release(queue);
// 设置视频输出到BGRA中存储帧
NSString* key = (NSString*)kCVPixelBufferPixelFormatTypeKey;
NSNumber* value = [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA];
NSDictionary* videoSettings = [NSDictionary dictionaryWithObject:value forKey:key];
[captureOutput setVideoSettings:videoSettings];
//我们创建一个捕获会话
self.captureSession = [[AVCaptureSession alloc] init];
self.captureSession.sessionPreset = AVCaptureSessionPresetMedium;
if([self.captureSession respondsToSelector:@selector(addInput:)])
[self.captureSession addInput:captureInput];
if([self.captureSession respondsToSelector:@selector(addOutput:)])
[self.captureSession addOutput:captureOutput];
/*We add the Custom Layer (We need to change the orientation of the layer so that the video is displayed correctly)*/
self.customLayer = [CALayer layer];
self.customLayer.frame = self.view.bounds;
self.customLayer.transform = CATransform3DRotate(CATransform3DIdentity, M_PI/2.0f, 0, 0, 1);
self.customLayer.transform = CATransform3DScale(self.customLayer.transform,.7,.7,1);
self.customLayer.transform = CATransform3DTranslate(self.customLayer.transform,-23,0,0);
self.customLayer.contentsGravity = kCAGravityResizeAspectFill;
[self.view.layer addSublayer:self.customLayer];
[self.captureSession startRunning];
//初始化结束
【问题讨论】:
-
使用
VideoSettings属性。 -
确保你不会忘记添加 iphone5 Default-568h@2x.png
-
@Nitin,是的,我添加了 Default-568h@2x.png
-
好的,那么我希望您正确检查其设备是否为 iphone5 是否正确..?如果是,那么您还将图层大小设置为标准设备,所以请您与您的问题分享此代码,那么您可以理解您的内容
-
是的,检查正确。并且在 3.5" 屏幕中也给出相同的尺寸 360 X 480。我已经检查了更改图层大小但没有更改。添加有问题的代码。
标签: iphone ios avcapturesession video-recording