Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to choose the a pixel format type (kCVPixelBufferPixelFormatTypeKey) for use with AVAssetReader?
    primarykey
    data
    text
    <p>We are using <code>AVAssetReader</code> and <code>AVAssetWriter</code> somewhat in the style as noted in <a href="https://stackoverflow.com/questions/8191840/video-encoding-using-avassetwriter-crashes">Video Encoding using AVAssetWriter - CRASHES</a> basically to read a video what we got from the photo gallery / asset library then writing it at a different bit rate to reduce its size (for eventual network upload).</p> <p>The trick to getting this to work for us was to specify a <code>kCVPixelBufferPixelFormatTypeKey</code> key and value in the <code>outputSettings</code> on <code>AVAssetReaderTrackOutput</code>, something like this:</p> <pre><code>NSDictionary *outputSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]; readerTrackOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:src_track outputSettings:outputSettings]; </code></pre> <p>So basically we used the <code>kCVPixelFormatType_32BGRA</code> value for the <code>kCVPixelBufferPixelFormatTypeKey</code> key. </p> <p>But apparently there are many possible pixel format types that we could choose from. Running the code noted in <a href="http://developer.apple.com/library/mac/#qa/qa1501/_index.html" rel="nofollow noreferrer">Technical Q&amp;A QA1501: Core Video - Available Pixel Formats</a> on an iOS 6.0.1 iPhone device, here's the list of support pixel format types that it shows:</p> <pre><code>Core Video Supported Pixel Format Types: Core Video Pixel Format Type: 32 Core Video Pixel Format Type: 24 Core Video Pixel Format Type: 16 Core Video Pixel Format Type (FourCC): L565 Core Video Pixel Format Type (FourCC): 2vuy Core Video Pixel Format Type (FourCC): yuvs Core Video Pixel Format Type (FourCC): yuvf Core Video Pixel Format Type: 40 Core Video Pixel Format Type (FourCC): L008 Core Video Pixel Format Type (FourCC): 2C08 Core Video Pixel Format Type (FourCC): r408 Core Video Pixel Format Type (FourCC): v408 Core Video Pixel Format Type (FourCC): y408 Core Video Pixel Format Type (FourCC): y416 Core Video Pixel Format Type (FourCC): BGRA Core Video Pixel Format Type (FourCC): b64a Core Video Pixel Format Type (FourCC): b48r Core Video Pixel Format Type (FourCC): b32a Core Video Pixel Format Type (FourCC): b16g Core Video Pixel Format Type (FourCC): R10k Core Video Pixel Format Type (FourCC): v308 Core Video Pixel Format Type (FourCC): v216 Core Video Pixel Format Type (FourCC): v210 Core Video Pixel Format Type (FourCC): v410 Core Video Pixel Format Type (FourCC): r4fl Core Video Pixel Format Type (FourCC): grb4 Core Video Pixel Format Type (FourCC): rgg4 Core Video Pixel Format Type (FourCC): bgg4 Core Video Pixel Format Type (FourCC): gbr4 Core Video Pixel Format Type (FourCC): 420v Core Video Pixel Format Type (FourCC): 420f Core Video Pixel Format Type (FourCC): 411v Core Video Pixel Format Type (FourCC): 411f Core Video Pixel Format Type (FourCC): 422v Core Video Pixel Format Type (FourCC): 422f Core Video Pixel Format Type (FourCC): 444v Core Video Pixel Format Type (FourCC): 444f Core Video Pixel Format Type (FourCC): y420 Core Video Pixel Format Type (FourCC): f420 Core Video Pixel Format Type (FourCC): a2vy Core Video Pixel Format Type (FourCC): L00h Core Video Pixel Format Type (FourCC): L00f Core Video Pixel Format Type (FourCC): 2C0h Core Video Pixel Format Type (FourCC): 2C0f Core Video Pixel Format Type (FourCC): RGhA Core Video Pixel Format Type (FourCC): RGfA </code></pre> <p>Even though <code>kCVPixelFormatType_32BGRA</code> worked (at least seemingly) for us, we are curious as to whether there is a better choice than that from the above list. How should we go about picking out the right pixel format type to us?</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.
 

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