MorningStar
MorningStar

Reputation: 31

No image on recorded video by GPUImage2

No image on recorded video by GPUImage2. Here is my example. I will appreciate if there is some one could help me find out a solution.

@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
        }
    }
}    

Upvotes: 1

Views: 99

Answers (1)

Yash Thaker
Yash Thaker

Reputation: 44

you forgot to add target to movieOutput.

camera.addTarget(movieOutput!)

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

Upvotes: 1

Related Questions