Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>With a little more searching and reading I have a working solution. Don't know that it is best method, but so far, so good.</p> <p>In my setup area I've setup an AVAssetWriterInputPixelBufferAdaptor. The code addition looks like this.</p> <pre><code>InputWriterBufferAdaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput: inputWriterBuffer sourcePixelBufferAttributes: nil]; [inputWriterBufferAdaptor retain]; </code></pre> <p>For completeness to understand the code below, I also have these three lines in the setup method.</p> <pre><code>fpsOutput = 30; //Some possible values: 30, 10, 15 24, 25, 30/1.001 or 29.97; cmTimeSecondsDenominatorTimescale = 600 * 100000; //To more precisely handle 29.97. cmTimeNumeratorValue = cmTimeSecondsDenominatorTimescale / fpsOutput; </code></pre> <p>Instead of applying a retiming to a copy of the sample buffer. I now have the following three lines of code that effectively does the same thing. Notice the withPresentationTime parameter for the adapter. By passing my custom value to that, I gain the correct timing I'm seeking.</p> <pre><code>CVPixelBufferRef myImage = CMSampleBufferGetImageBuffer( sampleBuffer ); imageSourceTime = CMTimeMake( writtenFrames * cmTimeNumeratorValue, cmTimeSecondsDenominatorTimescale); appendSuccessFlag = [inputWriterBufferAdaptor appendPixelBuffer: myImage withPresentationTime: imageSourceTime]; </code></pre> <p>Use of the AVAssetWriterInputPixelBufferAdaptor.pixelBufferPool property may have some gains, but I haven't figured that out.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload