Tag: yuv

如何获取原始的YUV420p相机数据

我不知道使用哪个值来获取原始YUV420p数据。 代码如下: AVCaptureVideoDataOutput *output = [[AVCaptureVideoDataOutput alloc] init]; output.alwaysDiscardsLateVideoFrames = YES; output.videoSettings = @{(id)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_420YpCbCr8BiPlanarFullRange]}; //output.videoSettings = @{(id)kCVPixelBufferPixelFormatTypeKey: [NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA]}; dispatch_queue_t queue; queue = dispatch_queue_create("CameraQueue", NULL); [output setSampleBufferDelegate:self queue:queue]; [session addOutput:output]; 我注意到kCVPixelFormatType有一些值,有人知道哪个值是正确的获取原始YUV420p数据? kCVPixelFormatType_420YpCbCr8Planar kCVPixelFormatType_420YpCbCr8PlanarFullRange kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange kCVPixelFormatType_420YpCbCr8BiPlanarFullRange 可以是其中之一?

为什么AVFoundation不能在iOS设备上接受我的平面像素缓冲区?

我一直在努力弄清楚我的代码有什么问题。 我正在创build一个平面CVPixelBufferRef写入AVAssetWriter 。 这个像素缓冲区是通过一些其他的过程手动创build的(也就是说,我没有从相机或类似的东西那里得到这些样本)。 在iOS模拟器上,添加示例并创build有效的输出影片没有任何问题。 但是,在设备上,它立即在第一个样本失败,并提供less于无用的错误信息: AVAssetWriterError: Error Domain=AVFoundationErrorDomain Code=-11800 "The operation could not be completed" UserInfo={NSUnderlyingError=0x12fd2c670 {Error Domain=NSOSStatusErrorDomain Code=-12780 "(null)"}, NSLocalizedFailureReason=An unknown error occurred (-12780), NSLocalizedDescription=The operation could not be completed} 我对像素格式很陌生,如果我以某种方式创build了无效的像素缓冲区,我不会感到惊讶,但在模拟器(即OS X)上工作得很好的事实让我感到困惑。 这是我的代码: const int pixelBufferWidth = img->get_width(); const int pixelBufferHeight = img->get_height(); size_t planeWidths[3]; size_t planeHeights[3]; size_t planeBytesPerRow[3]; void* planeBaseAddresses[3]; for (int […]

在YUV420p上有很多GREEN Color – >在iOS上的OpenGL 2.0 Shader中使用RGB

我想使用ffmpeg和OpenGL ES 2.0为iOS制作电影播放器​​,但是我遇到了一些问题。 输出RGB图像有很多绿色。 这是代码和图像 480×320宽度和高度: 512×512纹理宽度和高度 我从ffmpeg AVFrame获得了YUV420p行数据。 for (int i = 0, nDataLen = 0; i < 3; i++) { int nShift = (i == 0) ? 0 : 1; uint8_t *pYUVData = (uint8_t *)_frame->data[i]; for (int j = 0; j < (mHeight >> nShift); j++) { memcpy(&pData->pOutBuffer[nDataLen], pYUVData, (mWidth >> nShift)); pYUVData […]

如何把YUV转换成CIImage for iOS

我正在尝试将YUV图像转换为CIIMage,最后是UIImage。 我是相当新手,试图找出一个简单的方法来做到这一点。 从我学到的东西,从iOS6 YUV可以直接用来创buildCIImage,但正如我想创build它,CIImage只有一个零值。 我的代码是这样的 – > NSLog(@"Started DrawVideoFrame\n"); CVPixelBufferRef pixelBuffer = NULL; CVReturn ret = CVPixelBufferCreateWithBytes( kCFAllocatorDefault, iWidth, iHeight, kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, lpData, bytesPerRow, 0, 0, 0, &pixelBuffer ); if(ret != kCVReturnSuccess) { NSLog(@"CVPixelBufferRelease Failed"); CVPixelBufferRelease(pixelBuffer); } NSDictionary *opt = @{ (id)kCVPixelBufferPixelFormatTypeKey : @(kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) }; CIImage *cimage = [CIImage imageWithCVPixelBuffer:pixelBuffer options:opt]; NSLog(@"CURRENT CIImage -> %p\n", cimage); […]

YUV到苹果A4的RGBA,我应该使用着色器还是NEON?

我正在为Apple TV编写媒体播放器框架,使用OpenGL ES和ffmpeg。 在OpenGL ES上渲染需要转换为RGBA,使用swscale软转换的速度非常慢,所以使用互联网上的信息我提出了两个想法:使用霓虹灯(如这里 )或使用片段着色器和GL_LUMINANCE和GL_LUMINANCE_ALPHA。 正如我对OpenGL几乎一无所知,第二个选项仍然不工作:) 你可以给我任何指针如何进行? 先谢谢你。

CVOpenGLESTextureCacheCreateTextureFromImage返回错误6683

我目前正在尝试使用YUV420格式(双平面)在openGL中绘制图像。 我收到原始数据,并试图将其parsing为CVPixelBuffer,然后使用CVOpenGLESTextureCacheCreateTextureFromImage传递所述缓冲区。 虽然在parsing到CVPixelBuffer时我没有收到任何错误,但在尝试传入CVOpenGLESTextureCacheCreateTextureFromImage时收到错误(-6683)。 我正在尽我所能去关注苹果的GLCameraRipple示例代码 – 除此之外,我使用的是原始图像数据,而不是来自相机的数据。 希望有人能解释我在这里错过了什么 – 我认为这是一个缺失的属性… FYI中,平面0是Y平面,平面1是UV平面 – 其中UV平面应该是Y平面宽度和高度的一半。 size_t numPlanes = image->GetNumPlanes(); size_t planeWidth[numPlanes]; size_t planeHeight[numPlanes]; size_t scanWidth[numPlanes]; void *planeIndex[numPlanes]; for(int i = 0; i<numPlanes; i++){ i<1 ? planeWidth[i] = image->GetWidth() : planeWidth[i] = image->GetWidth()/2; i<1 ? planeHeight[i] = image->GetHeight() : planeWidth[i] = image->GetHeight()/2; scanWidth[i] = image->GetScanWidth(i); planeIndex[i] = image->GetPlanePointer(i); } […]