如何在GPUImageVideoCamera中添加水印

时间:2016-12-24 10:42:03

标签: ios swift gpuimage watermark

我有一个关于GPUImage的问题,我想录制带有水印的视频,我可以添加到视频滤镜效果,但添加的水印没有出现。代码如下:

    videoCamera = GPUImageVideoCamera(sessionPreset: AVCaptureSessionPresetHigh, cameraPosition: .front)
    videoCamera.outputImageOrientation = UIInterfaceOrientation.portrait
    videoCamera.horizontallyMirrorRearFacingCamera = false
    videoCamera.horizontallyMirrorFrontFacingCamera = false
    filter = GPUImageBrightnessFilter()
    videoCamera.addTarget(filter)

    filterImageView = GPUImageView(frame: view.bounds)
    view.addSubview(filterImageView)
    filter.addTarget(filterImageView)

    // waterMark
    let imageView = UIImageView(frame: CGRect(x: 100, y: 100, width: 100, height: 100))
    imageView.image = UIImage(named: "watermark.png")

    let subView = UIView(frame: CGRect(x: 0, y: 0, width: view.frame.size.width, height: view.frame.size.height))
    subView.backgroundColor = UIColor.red
    imageView.center = subView.center
    subView.addSubview(imageView)


    let uielement = GPUImageUIElement(view: subView)
    let markFilter = GPUImageAlphaBlendFilter()
    markFilter.mix = 1.0

    filter.addTarget(markFilter)
    uielement?.addTarget(filter)
    videoCamera.addTarget(markFilter)
    videoCamera.startCapture()

    uielement?.frameProcessingCompletionBlock = {filter, time in
        uielement?.update()
    }
我尝试了很多方法,无法解决这个问题,如果你能在这里得到答案,将不胜感激

0 个答案:

没有答案