GPUImageMovieWriter - 由audioEncodingTarget

时间:2015-05-15 04:57:56

标签: gpuimage

我尝试使用GPUImage库录制视频。录制的剪辑以黑框结束。我知道这是由 audioEncodingTarget 引起的,这是一项非常昂贵的操作。这已经讨论了很多,但我仍然没有找到解决方案。 这是我的代码:

GPUCameraRecorder class init

    videoCamera = GPUImageVideoCamera(sessionPreset: AVCaptureSessionPresetiFrame960x540, cameraPosition: .Back)
    videoCamera.outputImageOrientation = .LandscapeRight;
    videoCamera.horizontallyMirrorFrontFacingCamera = true

    filter = GPUImageFilter()
    videoCamera.addTarget(filter)

    view = GPUImageView(frame: frame)
    view.fillMode = kGPUImageFillModePreserveAspectRatioAndFill

    movieWriter = GPUImageMovieWriter(movieURL: output, size: view.frame.size)
    movieWriter?.encodingLiveVideo = true

    filter?.addTarget(movieWriter!)
    filter?.addTarget(view as GPUImageView)

    videoCamera.audioEncodingTarget = self.movieWriter!
    videoCamera.startCameraCapture()

开始录制功能

func startRecording(){
    println("Start recording.")
    recording = true

    dispatch_async(dispatch_get_main_queue()) {
        var res = self.videoCamera.addAudioInputsAndOutputs()
        println(res)

        self.movieWriter!.startRecording()            
    }
}

结束录制功能

func stopRecording(){
    println("Recording end.")

    dispatch_async(dispatch_get_main_queue()) {            
        self.filter?.removeTarget(self.movieWriter!)
        self.videoCamera.audioEncodingTarget = nil
        self.movieWriter!.finishRecording()

        self.putTorchOff()
        self.delegate?.recordingEnd()

        println("completed")
    }
 }

有什么建议吗?有人找到了一种没有黑框的方法吗?

1 个答案:

答案 0 :(得分:4)

你试过这个吗?

在GPUImageMovieWriter.m中 添加代码:

[DefaultEvent("Click")]
public class MyRadionButton : RadionButton {
}

https://github.com/BradLarson/GPUImage/issues/1255