Tag: cvpixelbuffer

为什么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 […]

在Swift中从CVPixelBufferRef获取像素值

我怎样才能从一个CVPixelBufferRef RGB(或任何其他格式)的像素值? 我尝试了很多方法,但没有成功。 func captureOutput(captureOutput: AVCaptureOutput!, didOutputSampleBuffer sampleBuffer: CMSampleBuffer!, fromConnection connection: AVCaptureConnection!) { let pixelBuffer: CVPixelBufferRef = CMSampleBufferGetImageBuffer(sampleBuffer)! CVPixelBufferLockBaseAddress(pixelBuffer, 0) let baseAddress = CVPixelBufferGetBaseAddress(pixelBuffer) //Get individual pixel values here CVPixelBufferUnlockBaseAddress(pixelBuffer, 0) }