【发布时间】:2012-08-23 01:22:45
【问题描述】:
我正在使用 AVFoundation 在 OSX 10.8 上进行一些屏幕录制。我正在使用 sessionPreset "AVCaptureSessionPresetPhoto" 来记录整个屏幕。我想更改的一件事是创建的电影文件的质量。
似乎需要 AVCaptureSessionPresetPhoto 才能实际捕获全屏而不进行剪辑。
"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."
但是,对于视频输入预设,唯一的选项是这些常量: 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 可以在不裁剪的情况下捕获全屏,但最终的质量有些令人失望。由于默认使用的比特率较低,存在可见的伪影。
如何提高最终录制的比特率?
以下是我当前代码的示例。
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];
【问题讨论】: