DZone Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world
Capture ISight (Macbook) Video With Objective-C QTKit
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
}





