次の AVAssetWriterInputPixelBufferAdaptor があります。
NSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];
[attributes setObject:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey];
[attributes setObject:[NSNumber numberWithUnsignedInt:frameSize.width] forKey:(NSString*)kCVPixelBufferWidthKey];
[attributes setObject:[NSNumber numberWithUnsignedInt:frameSize.height] forKey:(NSString*)kCVPixelBufferHeightKey];
adaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:attributes];
そして、次を使用して、2 つのプレーン (ビデオ形式タイプ kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange) から作成されたピクセル バッファーを追加しようとしています。
//Pixel buffer
CVPixelBufferRef buffer = NULL;
/*Pixel options*/
NSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:
[NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,
[NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey,
nil]
void* planesAdress[2] = { (void*)firstFrameGray, (void*)firstFrameUV};
size_t planesWitdh[2] = {640, 320};
size_t planesHeight[2] = { 480, 240};
size_t planesBytesPerRow[2] = { 640, 640};
CVReturn retw = CVPixelBufferCreateWithPlanarBytes(kCFAllocatorDefault, 640, 480, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, nil, nil, 2,planesAdress, planesWitdh, planesHeight, planesBytesPerRow, NULL, NULL, NULL, &buffer);
この時点で、バッファが null ではなく、CVPixelBufferIsPlanar が true であることを確認できます。
しかし、バッファを追加しようとするたびに、呼び出しに対して NO が返されます (この呼び出しは最初のフレームにのみ使用されます)。
[adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero];
エラーはエラーです。 12780.)", NSLocalizedDescription=操作を完了できませんでした}