Save videoStream to file in iOS - change color space efficiently

#1

Hi,
I’m trying to save a video from OF to file in iOS.

I found some good code to do that here:
https://github.com/adam-roth/screen-cap-view

And it works quite well, but I have some problems of color space.
original image:

video frame saved:

AVAssetWriterInputPixelBufferAdaptor gives me error if I change the color space from ARGB to RGBA.

NSDictionary* bufferAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithInt:kCVPixelFormatType_32ARGB], kCVPixelBufferPixelFormatTypeKey, nil];

AVAssetWriterInputPixelBufferAdaptor* avAdaptor = [[AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:videoWriterInput sourcePixelBufferAttributes:bufferAttributes] retain];

What is the most efficient way to change a buffer from RGBA to ARGB?

Did anyone experience other strategies to work with AVAssetWriter to feed directly oF video stream?