1

I'm having trouble adding labels to display the current time on the video, but I do not know where to start. I found an example of an apple edit video: https://developer.apple.com/library/content/samplecode/ReaderWriter/Introduction/Intro.html.

I'm trying to add AVAssetWriterInputPixelBufferAdaptor in AVAssetWriterInput, but I crashed when calling function: append (_ pixelBuffer: CVPixelBuffer, withPresentationTime presentationTime: CMTime) -> Bool

What I want to know is how can I paint up a similar time as a video https://www.youtube.com/watch?v=9mmrBDA1baY

Update:

I was a bit confused about append PixelBuffer with an adapter, but it was just a matter of connecting the frames back to the video. At Apple's instance, every thing was handled with CMSampleBuffer in "sampleBufferProcessor" The next thing to do is to process CVPixelBuffer how to add a layer or text to the current time (automatically change in real time) This is what I found when watching WWDC 2014 Help me in the right direction enter image description here

ReasonAmu
  • 43
  • 5

1 Answers1

1

If you just want to add overlays on video, you can use AVVideoCompositionCoreAnimationTool. Add animation of text change on CATextLayer and export it.

Tiko
  • 485
  • 4
  • 10
  • while a recording video can I use `AVVideoCompositionCoreAnimationTool` to add text dynamically on each frame? If yes, any example? or is it only for already available video file? (re-editing/re-encoding) – user924 Mar 01 '18 at 11:42
  • @user924 no you can’t, its only for postprocessing, for real time capture you can render your text overlays on each frame directly to ‘CVPixelBufferRef’ and write that frames via ‘AVAssetWriter’. – Tiko Mar 03 '18 at 14:59
  • yes, similar way how I was trying to do, but actually I didn't find a way to directly to add, because when I edit CIImage (which data was referenced directly from CVPixelBuffer) it creates a new one and to convert it back to buffer requires many CPU usage: https://stackoverflow.com/questions/49066195/what-is-the-best-way-to-record-a-video-with-augmented-reality – user924 Mar 03 '18 at 17:57