Set permission in QTCapture?

I am recording from a webcam. The camera looks great in PhotoBooth. However, when I view it in my program using QTCaptureView or write it to a file, it is very, very slow. The reason is that QuickTime gives me the highest possible resolution of 1600x1200. How can I get a more reasonable size for both my QTCaptureView and my post?

+3
source share
3 answers

As described here , you can set the pixel buffer attributes in the output file of your QTCaptureSession to change the resolution of the captured video. For example:

[[[myCaptureSession outputs] objectAtIndex:0] setPixelBufferAttributes: [NSDictionary dictionaryWithObjectsAndKeys:
                                                                [NSNumber numberWithInt:480], kCVPixelBufferHeightKey,
                                                                [NSNumber numberWithInt:640], kCVPixelBufferWidthKey, nil]];

sets the resolution of the video to 640x480 for the first output in the capture session. It also needs to adjust the camera settings themselves in order to return image frames of this size (if supported by the camera hardware).

You can also use basic MPEG4 encoding instead of h.264 to record live video. This can be set using code similar to the following:

NSArray *outputConnections = [mCaptureMovieFileOutput connections];
QTCaptureConnection *connection;
for (connection in outputConnections)
{
    if ([[connection mediaType] isEqualToString:QTMediaTypeVideo])
            [mCaptureMovieFileOutput setCompressionOptions:[QTCompressionOptions compressionOptionsWithIdentifier:@"QTCompressionOptionsSD480SizeMPEG4Video"] forConnection:connection];
}
Coding

h.264, especially the Quicktime implementation, uses much more processor power for encoding than basic MPEG4.

+7
source

(setPixelBufferAttributes:) , , (1280 x 1024 MBP), () .

, , , setPixelBufferAttributes .

, , - .

10.5.8/9L30, MBP GeForce 8600M. , , QTCompressionOptionsSD240SizeH264Video , .

rdar://7447812

+3

:

you cannot directly define the definition on the capture side. Rather, it is the result of a capture session that defines the definition. eg.

  • if you write to QtCaptureDecompressedVideoOutput, you must specify a definition for this object.
0
source

Source: https://habr.com/ru/post/1707207/


All Articles