首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >AVCaptureMovieFileOutput的意外行为

AVCaptureMovieFileOutput的意外行为
EN

Stack Overflow用户
提问于 2014-01-06 07:30:36
回答 1查看 224关注 0票数 1

我正在用AVCaptureMovieFIleOutput,制作一部银幕电影,但它显示出了意想不到的行为。

例如,如果我发送的是cropRect参数,捕获的电影是好的,但如果我制作的电影全屏幕,而不是电影文件,它是显示一个文件夹。我怎么才能摆脱它?

代码是:

代码语言:javascript
复制
    // 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];
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-11 06:58:09

必须使用setSessionPreset属性。

sessionPreset的默认值是AVCaptureSessionPresetHigh,它不适用于全屏截图。必须提供任何其他预置。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/20945097

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档