在我 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];
//初始化结束