Note that there are some explanatory texts on larger screens.

plurals
  1. POSaving sampleBuffer into CFArray
    primarykey
    data
    text
    <p>I have been trying to create a circular buffer of 60 frames of video from that come from AVCaptureOutput and then I need to write the frames to AVAssetWriter after an event occurs. I think it would have to work in a similar way to how this app <a href="http://itunes.apple.com/us/app/precorder-video-camera-for/id412558814?mt=8" rel="nofollow noreferrer">http://itunes.apple.com/us/app/precorder-video-camera-for/id412558814?mt=8</a> records a set amount before the record button is pressed.</p> <p>The prior method that I have been using for the circular buffer was to add the sampleBuffer from the output into an NSArray, by means of converting it to a UIImage. This works fine except that, as far as I can see, the array fills up with uncompressed video frames too quickly (giving me memory warnings and then crashing) and also if the video quality is set high, the frame rate is too slow, due to the conversions to UIImage objects. So therefore now I have been trying to add the sampleBuffer into a CFMutableArray - as it means that I don't have to convert it to a UIImage, thus hopefully picking up the frame rate. However, there are very very few examples of anyone having done this. I read <a href="https://stackoverflow.com/questions/7674892/save-samplebuffer-in-array-avfoundation">Save sampleBuffer in array (AVFoundation)</a> and understood to do the following: </p> <p>To initialise: </p> <pre><code>CFMutableArrayRef arrayOne = CFArrayCreateMutable( NULL, 0, &amp;kCFTypeArrayCallBacks ); </code></pre> <p>To insert: </p> <pre><code>CFArrayInsertValueAtIndex(arrayOne, index, sampleBuffer); </code></pre> <p>To convert back to sampleBuffer:</p> <pre><code>CMSampleBufferRef newSampleBuffer = (CMSampleBufferRef)CFArrayGetValueAtIndex(arrayOne, cfarrIndex); </code></pre> <p>However, when I go to use the the 'newSampleBuffer', it doesn't allow me to use it, generally stopping the code or giving a bad access error.</p> <p>So I guess my question is, does anyone know if what I am trying to do is possible?? Or if there was any other way to do this? </p> <p>Thanks in advance! </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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