为什么在 OSX 中捕获屏幕时帧速率变慢?

Why do I get Slower Frame Rate while Capturing Screen in OSX?

我指的是 AVScreenShack example.I 甚至取消了预览功能,看看它是否有所改进。但是,跳帧非常明显。一直以为自己的电脑不够强大,但是用QuickTime Player录屏的时候,视频很流畅

如何改进以下代码以获得高 fps 输出?

func startRecording(){
        mSession = AVCaptureSession()
        mSession?.sessionPreset = AVCaptureSessionPresetHigh
        let displayId : CGDirectDisplayID = CGMainDisplayID()

        let session : AVCaptureSession
        if mSession != nil {
            session = mSession!
        }else{
            return
        }

        let input : AVCaptureScreenInput = AVCaptureScreenInput(displayID: displayId)
        input.minFrameDuration = CMTimeMake(1, 35)
        if let rect = delegate?.cropRect() {
            input.cropRect = rect
        }

        if session.canAddInput(input) {
            session.addInput(input)
        }else{
            return
        }

        mMovieFileOutput = AVCaptureMovieFileOutput()

        if session.canAddOutput(mMovieFileOutput) {
            session.addOutput(mMovieFileOutput!)
        }

        mSession?.startRunning()
        mMovieFileOutput?.movieFragmentInterval = kCMTimeInvalid
        mMovieFileOutput?.startRecording(toOutputFileURL: URL(fileURLWithPath:"/Users/Tester/Desktop/capture.mov"), recordingDelegate: self)

    }

您可以通过降低最小帧持续时间来获得更高的帧率:

input.minFrameDuration = CMTimeMake(1, 60)

N.B。这并不能保证更高的帧率,但它允许一个。