AVFoundation - Retiming CMSampleBufferRef Video Output

前端 未结 2 2087
抹茶落季
抹茶落季 2021-01-30 10:07

First time asking a question here. I\'m hoping the post is clear and sample code is formatted correctly.

I\'m experimenting with AVFoundation and time lapse photography.

2条回答
  •  长情又很酷
    2021-01-30 10:28

    OK, I found the bug in my first post.

    When using

    myStatus = CMSampleBufferCreateCopyWithNewTiming(kCFAllocatorDefault,
                                                     sampleBuffer,
                                                     1,
                                                     &sampleTimingInfo, 
                                                     &newSampleBuffer);
    

    you need to balance that with a CFRelease(newSampleBuffer);

    The same idea holds true when using a CVPixelBufferRef with a piexBufferPool of an AVAssetWriterInputPixelBufferAdaptor instance. You would use CVPixelBufferRelease(yourCVPixelBufferRef); after calling the appendPixelBuffer: withPresentationTime: method.

    Hope this is helpful to someone else.

提交回复
热议问题