Render dynamic text onto CVPixelBufferRef while recording video

前端 未结 4 2186
暗喜
暗喜 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:42

    I asked Apple DTS about this same issue as all approaches I had were running really slow or doing odd things and they sent me this:

    https://developer.apple.com/documentation/avfoundation/avasynchronousciimagefilteringrequest?language=objc

    Which got me to a working solution really quickly! you can bypass the CVPixelBuffer altogether using CIFilters, which IMHO is much easier to work with. So if you don't actually NEED to use CVPixelBuffer, then this approach will become your new friend quickly.

    A combination of CIFilter(s) to composite the source image and the image with the text I generated for each frame did the trick.

    I hope this helps someone else!

提交回复
热议问题