I'm doing some screen recording on the OSX 10.8 with AVFoundation. I'm using the sessionPreset "AVCaptureSessionPresetPhoto" to record the entire screen. One thing I'd like to change is the quality of the movie file that is created.
AVCaptureSessionPresetPhoto seems to be required to actually capture the full screen without clipping.
According to the documentation here: http://developer.apple.com/library/mac/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html
"You use this property to customize the quality level or bitrate of the output. For possible values of sessionPreset, see “Video Input Presets.” The default value is AVCaptureSessionPresetHigh."
However, for Video Input Presets, the only options are these constants: http://developer.apple.com/library/ios/#documentation/AVFoundation/Reference/AVCaptureSession_Class/Reference/Reference.html#//apple_ref/occ/cl/AVCaptureSession
NSString *const AVCaptureSessionPresetPhoto;
NSString *const AVCaptureSessionPresetHigh;
NSString *const AVCaptureSessionPresetMedium;
NSString *const AVCaptureSessionPresetLow;
NSString *const AVCaptureSessionPreset320x240;
NSString *const AVCaptureSessionPreset352x288;
NSString *const AVCaptureSessionPreset640x480;
NSString *const AVCaptureSessionPreset960x540;
NSString *const AVCaptureSessionPreset1280x720;
AVCaptureSessionPresetPhoto does the work of capturing the full screen without clipping, but the final quality is somewhat underwhelming. There are visible artifacts due to the lower bitrate that is used by default.
How can I go about increasing the bitrate of the final recording?
Below is a sample of my current code.
mSession = [[AVCaptureSession alloc] init];
mSession.sessionPreset = AVCaptureSessionPresetPhoto;
CGDirectDisplayID displayId = kCGDirectMainDisplay;
AVCaptureScreenInput *input = [[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
if (!input) {
mSession = nil;
return;
}
if ([mSession canAddInput:input]){
[mSession addInput:input];
}
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([mSession canAddOutput:mMovieFileOutput])
[mSession addOutput:mMovieFileOutput];
[mSession startRunning];
if ([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]])
{
NSError *err;
if (![[NSFileManager defaultManager] removeItemAtPath:[destPath path] error:&err])
{
NSLog(@"Error deleting existing movie %@",[err localizedDescription]);
}
}
[mMovieFileOutput startRecordingToOutputFileURL:destPath recordingDelegate:self];
mTimer = [NSTimer scheduledTimerWithTimeInterval:5 target:self selector:@selector(finishRecord:) userInfo:nil repeats:NO];