We use AVAssetReader and AVAssetWriter somewhat in the style noted in Video Encoding using AVAssetWriter - CRASHES , mainly to read the video that we received from the photo gallery / resource library, then recording it at a different bit rate to reduce its size (for possible network boot).
The trick for this was that we had to specify the kCVPixelBufferPixelFormatTypeKey key and the outputSettings value on AVAssetReaderTrackOutput , something like this:
NSDictionary *outputSettings = [NSDictionary dictionaryWithObject:[NSNumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]; readerTrackOutput = [[AVAssetReaderTrackOutput alloc] initWithTrack:src_track outputSettings:outputSettings];
So basically we used the value kCVPixelFormatType_32BGRA for the key kCVPixelBufferPixelFormatTypeKey .
But apparently there are many possible types of pixel formats that we could choose. Running the code noted in Technical Q & A QA1501: The main video is the available pixel formats on the iPhone iOS 6.0.1 device, here is a list of the supported types of pixel formats that it shows:
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
Despite the fact that kCVPixelFormatType_32BGRA worked (at least at first glance) for us, we are curious if there is a better choice than the above list. How should we choose the type of rectangular pixel format for us?
source share