当我继续尝试录制视频然后完成录制时,我遇到了这样的崩溃
FirstGPUImage[768:179067] *** Terminating app due to uncaught
exception 'NSInternalInconsistencyException', reason: 'Unable to create
an OpenGL ES 2.0 context. The GPUImage framework requires OpenGL ES 2.0
support to work.'
不知道是不是我自己的代码或者GPUImageMovieWrite有问题,所以想请教一下为什么!
这是我的代码:
func startTest(){
mCamera.addAudioInputsAndOutputs()//避免录制第一帧黑屏
let name = Date().timeIntervalSince1970
videoUrl = URL(fileURLWithPath: "\(NSTemporaryDirectory())folder_demo\(name).mp4")
unlink(videoUrl?.path)
var size = CGSize(width: 480, height: 640)
movieWriter = GPUImageMovieWriter(movieURL:videoUrl, size:size )
movieWriter?.assetWriter.movieFragmentInterval = kCMTimeInvalid
movieWriter?.encodingLiveVideo = true
movieWriter?.setHasAudioTrack(true, audioSettings: nil)
ifFilter.addTarget(movieWriter)
self.mCamera.audioEncodingTarget = self.movieWriter
self.movieWriter?.startRecording()
liveTimer = Timer.scheduledTimer(timeInterval: 0.5, target: self, selector: #selector(updateTest), userInfo: nil, repeats: true)
}
@objc func updateTest(){
weak var ws = self
movieWriter?.finishRecording(completionHandler: {
ws?.startTest()
print(Date().timeIntervalSince1970)
})
}