1

I try using CVPixelBufferCreateWithPlanarBytes. I do not see any error returned by CVPixelBufferCreateWithPlanarBytes, VTCompressionSessionEncodeFrame. But the output callback gives an error kVTParameterErr. All the parameters for all the API s appears to be fine. Note: The same piece of code is working fine on mac.

  • I have the same problem. I've even converted the CVPixelBuffer to a UIImage to confirm that I've created it correctly and the contents look good, and they do. Yet it can't be converted to h264 and I don't understand which parameter is incorrect... – nevyn Oct 21 '16 at 23:52

1 Answers1

1

Had same problem. Buffer created with CVPixelBufferCreateWithPlanarBytes generates -12902 error, buffer created with CVPixelBufferCreate is encoded normally.

So instead of CVPixelBufferCreateWithPlanarBytes use:

// Create buffer   
CVPixelBufferCreate(..., &buffer);

// Lock base address (necessary to get and use plane pointers   
CVPixelBufferLockBaseAddress(buffer, 0);

// Get plane count  
size_t count = CVPixelDataGetPlaneCount(buffer);

// Repeat for all planes
for (size_t plane = 0; plane < count; plane++) {    
    void* ptr = CVPixelBufferGetBaseAddressOfPlane(buffer, plane);
    //write your plane data   
}

// Unlock base address  
CVPixelBufferUnlockBaseAddress(buffer, 0);  
abbro
  • 11
  • 1
  • Amazing :) I was trying to figure out what is going wrong with my implementation using CVPixelBufferCreateWithPlanarBytes, the image buffer passed to VTCompressionSessionEncodeFrame looked just fine in Xcode debugger, was getting first -12780, then after some tweaking -12902. Thanks! – bojan Feb 22 '21 at 02:39