BWSnippet

OS X Objective-C get all available video input devices

OS X Objective-C get all available video input devices

How to get a quick list of all available video input devies

Get a quick list of available video input devies

    NSArray * _captureDevices = [[NSArrayalloc] initWithArray: [QTCaptureDeviceinputDevicesWithMediaType:QTMediaTypeVideo]];
    NSLog(@" _captureDeviceCount count is %li" , (unsignedlong)_captureDevices.count);
    
    for (int i = 0; i < _captureDevices.count; i++)
    {
        QTCaptureDevice *capDevice = [_captureDevices objectAtIndex:i];
        NSLog(@"capDevice is: %@" , capDevice);
        NSLog(@"capDevice uniqueID is: %@" , capDevice.uniqueID);
    }

You use the uniqueID to decide what one you want to use. Like this:


        QTCaptureDevice *device = [QTCaptureDevice deviceWithUniqueID:@"0x1a120000046d0809"];


Where 0x1a120000046d0809 is an NSString that represents the device you want to use.

Tags

OS X Objective-C get all available video input devices