<!--
{
  "availability" : [
    "iOS: 4.0.0 -",
    "iPadOS: 4.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.6.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreVideo",
  "identifier" : "/documentation/CoreVideo/CVPixelBufferCreateWithIOSurface(_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Core Video"
    ],
    "preciseIdentifier" : "c:@F@CVPixelBufferCreateWithIOSurface"
  },
  "title" : "CVPixelBufferCreateWithIOSurface(_:_:_:_:)"
}
-->

# CVPixelBufferCreateWithIOSurface(_:_:_:_:)

Creates a single pixel buffer for the IO surface that you specify.

```
func CVPixelBufferCreateWithIOSurface(_ allocator: CFAllocator?, _ surface: IOSurfaceRef, _ pixelBufferAttributes: CFDictionary?, _ pixelBufferOut: UnsafeMutablePointer<Unmanaged<CVPixelBuffer>?>) -> CVReturn
```

## Parameters

`allocator`

The allocator to use for creating the buffer pool. Pass <doc://com.apple.documentation/documentation/CoreFoundation/kCFAllocatorDefault> for the `allocator` parameter to use the default allocator. See <doc://com.apple.documentation/documentation/CoreFoundation/predefined-allocators> for additional values you can use.

`surface`

The IOSurface to use in the pixel buffer.

`pixelBufferAttributes`

An optional dictionary that contains the attributes for the pixel buffer. See [Pixel Buffer Attribute Keys](/documentation/CoreVideo/pixel-buffer-attribute-keys) for possible values.

`pixelBufferOut`

On output, the newly created pixel buffer.

## Return Value

A Core Video result code. See [Result Codes](/documentation/CoreVideo/result-codes) for possible values.

## Discussion

Use [`CVPixelBufferRelease`](/documentation/CoreVideo/CVPixelBufferRelease) to release ownership of the `pixelBufferOut` object when you’re done with it.

> Important:
> If you are using IOSurface to share CVPixelBuffers between processes and those CVPixelBuffers are allocated via a CVPixelBufferPool, it is important that the CVPixelBufferPool does not reuse CVPixelBuffers whose IOSurfaces are still in use in other processes.
> 
> CoreVideo and IOSurface will take care of this for if you use IOSurfaceCreateMachPort and IOSurfaceLookupFromMachPort, but NOT if you pass IOSurfaceIDs.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)