Over a million developers have joined DZone.

Capture ISight (Macbook) Video With Objective-C QTKit

DZone's Guide to

Capture ISight (Macbook) Video With Objective-C QTKit

· ·
Free Resource
This is how we can capture video from Macbook iSight.
A Sample code from an IBAction button.

- (IBAction)startRecording:(id)sender
  // Create a new Capture Session
  mCaptureSession = [[QTCaptureSession alloc] init]; 
  //Connect inputs and outputs to the session
  BOOL success = NO;
  NSError *error;
  // Find a video device
  QTCaptureDevice *device = [QTCaptureDevice defaultInputDeviceWithMediaType:QTMediaTypeVideo];
  if(device) {
    success = [device open:&error];
    if(!success) {
      // Handle Error!
    // Add the video device to the session as device input
    mCaptureDeviceInput = [[QTCaptureDeviceInput alloc] initWithDevice:device];
    success = [mCaptureSession addInput:mCaptureDeviceInput error:&error];
    if(!success) {
      // Handle error
    // Associate the capture view in the UI with the session
    [mCaptureView setCaptureSession:mCaptureSession];
    // Start the capture session runing
    [mCaptureSession startRunning];
  } // End if device


Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}