GPUImage2录制的视频上没有图像。
这是我的例子。如果有人能帮我找到解决办法,我将不胜感激。

@IBAction func capture(_ sender: UIButton) {
    if (!isRecording) {
        do {
            self.isRecording = true
            let documentsDir = try FileManager.default.url(for:.documentDirectory, in:.userDomainMask, appropriateFor:nil, create:true)
            let fileURL = URL(string:"test.mp4", relativeTo:documentsDir)!
            do {
                try FileManager.default.removeItem(at:fileURL)
            } catch {
            }

            movieOutput = try MovieOutput(URL:fileURL, size:Size(width:480, height:640), liveVideo:true)
            camera.audioEncodingTarget = movieOutput
            movieOutput!.startRecording()
        } catch {
            fatalError("Couldn't initialize movie, error: \(error)")
        }
    } else {
        movieOutput?.finishRecording{
            self.isRecording = false
            self.camera.audioEncodingTarget = nil
            self.movieOutput = nil
        }
    }
}

最佳答案

您忘记将目标添加到电影输出。
camera.addTarget(电影输出!)

    do {
        movieOutput = try MovieOutput(URL: currentVideoUrl, size: videoSize, liveVideo: true)
        camera.audioEncodingTarget = movieOutput
        camera.addTarget(movieOutput!)
        movieOutput!.startRecording()
    } catch {
        print(error.localizedDescription)
    }

关于swift - GPUImage2在录制的视频上没有图像,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/54861096/

10-09 09:59