CSh*_*ing 5 objective-c video-processing avfoundation ios avcapturesession
我有以下 AVAssetWriterInputPixelBufferAdaptor:
\n\nNSMutableDictionary *attributes = [[NSMutableDictionary alloc] init];\n[attributes setObject:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange] forKey:(NSString*)kCVPixelBufferPixelFormatTypeKey];\n[attributes setObject:[NSNumber numberWithUnsignedInt:frameSize.width] forKey:(NSString*)kCVPixelBufferWidthKey];\n[attributes setObject:[NSNumber numberWithUnsignedInt:frameSize.height] forKey:(NSString*)kCVPixelBufferHeightKey];\n\nadaptor = [AVAssetWriterInputPixelBufferAdaptor assetWriterInputPixelBufferAdaptorWithAssetWriterInput:writerInput sourcePixelBufferAttributes:attributes];\nRun Code Online (Sandbox Code Playgroud)\n\n我尝试使用以下命令附加从 2 个平面创建的像素缓冲区(视频格式类型 kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange):
\n\n//Pixel buffer\nCVPixelBufferRef buffer = NULL;\n\n/*Pixel options*/\nNSDictionary *options = [NSDictionary dictionaryWithObjectsAndKeys:\n [NSNumber numberWithBool:YES], kCVPixelBufferCGImageCompatibilityKey,\n [NSNumber numberWithBool:YES], kCVPixelBufferCGBitmapContextCompatibilityKey,\n nil]\n\nvoid* planesAdress[2] = { (void*)firstFrameGray, (void*)firstFrameUV};\nsize_t planesWitdh[2] = {640, 320};\nsize_t planesHeight[2] = { 480, 240};\nsize_t planesBytesPerRow[2] = { 640, 640};\n\n\nCVReturn retw = CVPixelBufferCreateWithPlanarBytes(kCFAllocatorDefault, 640, 480, kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, nil, nil, 2,planesAdress, planesWitdh, planesHeight, planesBytesPerRow, NULL, NULL, NULL, &buffer);\nRun Code Online (Sandbox Code Playgroud)\n\n此时我可以检查缓冲区不为空并且 CVPixelBufferIsPlanar 为 true。
\n\n但是每次我尝试附加缓冲区时,它都会返回 NO 调用(此调用仅用于第一帧)
\n\n[adaptor appendPixelBuffer:buffer withPresentationTime:kCMTimeZero];\nRun Code Online (Sandbox Code Playgroud)\n\n错误为错误域=AVFoundationErrorDomain代码=-11800“操作无法完成”UserInfo=0x9ad800 {NSLocalizedFailureReason=发生未知错误(-12780),NSUnderlyingError=0x9aa200“操作无法\xe2\x80\x9a\xc3\ x84\xc3\xb4t 无法完成。(OSStatus 错误 -12780。)”,NSLocalizedDescription=操作无法完成}
\n| 归档时间: |
|
| 查看次数: |
2356 次 |
| 最近记录: |