Render dynamic text onto CVPixelBufferRef while recording video

前端 未结 4 2176
暗喜
暗喜 2021-02-09 16:56

I\'m recording video and audio using AVCaptureVideoDataOutput and AVCaptureAudioDataOutput and in the captureOutput:didOutputSampleBuffer:fromCon

4条回答
  •  情歌与酒
    2021-02-09 17:33

    Swift version of Bannings's answer.

            let combinedFilter = CIFilter(name: "CISourceOverCompositing")!
            combinedFilter.setValue(maskImage.oriented(.left), forKey: "inputImage")
            combinedFilter.setValue(inputImage, forKey: "inputBackgroundImage")
    
            let outputImage = combinedFilter.outputImage!
    
            let tmpcontext = CIContext(options: nil)
            tmpcontext.render(outputImage, to: pixelBuffer, bounds: outputImage.extent, colorSpace: CGColorSpaceCreateDeviceRGB())
    

提交回复
热议问题