---
title: "CVPixelBufferCreateWithIOSurface(_:_:_:_:)"
framework: corevideo
role: symbol
role_heading: Function
path: "corevideo/cvpixelbuffercreatewithiosurface(_:_:_:_:)"
---

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

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

## Declaration

```swift
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 doc://com.apple.corevideo/documentation/CoreVideo/pixel-buffer-attribute-keys for possible values.
- `pixelBufferOut`: On output, the newly created pixel buffer.

## Return Value

Return Value A Core Video result code. See Result Codes for possible values.

## Discussion

Discussion Use 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.

## See Also

### Creating pixel buffers

- [CVPixelBufferCreate(_:_:_:_:_:_:)](corevideo/cvpixelbuffercreate(_:_:_:_:_:_:).md)
- [CVPixelBufferCreateWithBytes(_:_:_:_:_:_:_:_:_:_:)](corevideo/cvpixelbuffercreatewithbytes(_:_:_:_:_:_:_:_:_:_:).md)
- [CVPixelBufferCreateWithPlanarBytes(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:)](corevideo/cvpixelbuffercreatewithplanarbytes(_:_:_:_:_:_:_:_:_:_:_:_:_:_:_:).md)
