Iphone 我用这个代码捕获图像,我必须录制视频,怎么做?

Iphone 我用这个代码捕获图像,我必须录制视频,怎么做?,iphone,objective-c,ipad,cocoa-touch,Iphone,Objective C,Ipad,Cocoa Touch,*我用这个代码捕获图像,但我必须在点击按钮时录制视频并保存,所以请告诉我该怎么做?事实上,我没有得到,因为我已经成功地捕获了图像并将其保存到我的相册中,但现在我还必须录制视频并存储它,所以请任何人给我更好的想法* 很抱歉,我无法编辑您的代码,但我提供了一些链接,可以帮助您完成任务 请查看这些链接 享受..很抱歉,我无法编辑您的代码,但我提供了一些链接,可以帮助您完成任务 请查看这些链接 享受..这篇关于为什么只发布指向其他资源的链接的答案没有帮助的元讨论是一篇好文章。这篇关于为什么只发布指向其他

*我用这个代码捕获图像,但我必须在点击按钮时录制视频并保存,所以请告诉我该怎么做?事实上,我没有得到,因为我已经成功地捕获了图像并将其保存到我的相册中,但现在我还必须录制视频并存储它,所以请任何人给我更好的想法*


很抱歉,我无法编辑您的代码,但我提供了一些链接,可以帮助您完成任务

请查看这些链接


享受..

很抱歉,我无法编辑您的代码,但我提供了一些链接,可以帮助您完成任务

请查看这些链接


享受..

这篇关于为什么只发布指向其他资源的链接的答案没有帮助的元讨论是一篇好文章。这篇关于为什么只发布指向其他资源的链接的答案没有帮助的元讨论是一篇好文章。
 - (void)viewDidLoad
   {
   front=NO;
   self.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
barPicker.value = hue;
    pickerArr=[[NSArray   alloc]initWithObjects:@"01",@"02",@"03",@"04",@"05",@"06",@"07",@"08",@"09",@"10", nil];
   flashlightOn=YES;
  [flashButton setImage:[UIImage imageNamed:@"off.png"] forState:UIControlStateNormal];
  [camraButton setImage:[UIImage imageNamed:@"camra.png"] forState:UIControlStateNormal];
session = [[AVCaptureSession alloc] init];
session.sessionPreset = AVCaptureSessionPresetMedium;
CALayer *viewLayer = self.vImagePreview.layer;
AVCaptureVideoPreviewLayer *captureVideoPreviewLayer = [[AVCaptureVideoPreviewLayer alloc] initWithSession:session];
captureVideoPreviewLayer.frame = self.vImagePreview.bounds;
 [self.vImagePreview.layer addSublayer:captureVideoPreviewLayer];
[self.vImagePreview addSubview:flashButton];
[self.vImagePreview addSubview:camraButton];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
 NSError *error = nil;
input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];
stillImageOutput = [[AVCaptureStillImageOutput alloc] init];
NSDictionary *outputSettings = [[NSDictionary alloc] initWithObjectsAndKeys:  AVVideoCodecJPEG, AVVideoCodecKey, nil];
 if (!input) {
    // Handle the error appropriately.
    NSLog(@"ERROR: trying to open camera: %@", error);
}
else
{
    [session addInput:input];
    [stillImageOutput setOutputSettings:outputSettings];
    [session addOutput:stillImageOutput];

}
[session startRunning];
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
}
    -(IBAction) captureNow
 {

if (!front)
{
    if (flashlightOn) {
        AVCaptureDevice *device1 = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
        if ([device1 hasTorch] && [device1 hasFlash])
        {
            [device1 lockForConfiguration:nil];
            [device1 setTorchMode:AVCaptureTorchModeOn];
            [device1 setFlashMode:AVCaptureFlashModeOn];
            [device1 unlockForConfiguration];
        }
    }
}

AVCaptureConnection *videoConnection = nil;

for (AVCaptureConnection *connection in stillImageOutput. connections) {
    for (AVCaptureInputPort *port in [connection inputPorts]) {
        if ([[port mediaType] isEqual:AVMediaTypeVideo]) {
            videoConnection = connection;
            break;
        }
    }
    if (videoConnection) {
        break;
    }
}

NSLog(@"about to request a capture from: %@", stillImageOutput);
[stillImageOutput captureStillImageAsynchronouslyFromConnection:videoConnection                                completionHandler:^(CMSampleBufferRef imageSampleBuffer, NSError *error)

 {
     CFDictionaryRef exifAttachments = CMGetAttachment(imageSampleBuffer, kCGImagePropertyExifDictionary, NULL);
     if (exifAttachments) {

     }
     else {
     }
     NSData *imageData = [AVCaptureStillImageOutput jpegStillImageNSDataRepresentation:imageSampleBuffer];

     image.image = [[UIImage alloc] initWithData:imageData];

    }];

  }