我正在使用 AVCaptureMovieFIleOutput 制作一部电影,但它显示出意想不到的行为。
就像,如果我发送cropRect参数,捕获的电影很好,但是如果我制作整个屏幕的电影而不是电影文件,它会显示一个文件夹。我怎么能摆脱它?
代码是:
// Create a capture session
mSession = [[AVCaptureSession alloc] init];
// If you're on a multi-display system and you want to capture a secondary display,
// you can call CGGetActiveDisplayList() to get the list of all active displays.
// For this example, we just specify the main display.
CGDirectDisplayID displayId = kCGDirectMainDisplay;
// Create a ScreenInput with the display and add it to the session
input = [[AVCaptureScreenInput alloc] initWithDisplayID:displayId];
[input setCropRect:rect];
if (!input) {
mSession = nil;
return;
}
if ([mSession canAddInput:input])
[mSession addInput:input];
// Create a MovieFileOutput and add it to the session
mMovieFileOutput = [[AVCaptureMovieFileOutput alloc] init];
if ([mSession canAddOutput:mMovieFileOutput])
[mSession addOutput:mMovieFileOutput];
// Start running the session
[mSession startRunning];
// Delete any existing movie file first
if ([[NSFileManager defaultManager] fileExistsAtPath:[destPath path]])
{
NSError *err;
if (![[NSFileManager defaultManager] removeItemAtPath:[destPath path] error:&err])
{
NSLog(@"Error deleting existing movie %@",[err localizedDescription]);
}
}
// Start recording to the destination movie file
// The destination path is assumed to end with ".mov", for example, @"/users/master/desktop/capture.mov"
// Set the recording delegate to self
[mMovieFileOutput startRecordingToOutputFileURL:destPath recordingDelegate:self];
答案 0 :(得分:1)
必须使用setSessionPreset
属性。
sessionPreset
的默认值为AVCaptureSessionPresetHigh
,它不适用于全屏捕获。将不得不为此提供任何其他预设。