<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.8.0 -",
    "tvOS: 10.2.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "VideoToolbox",
  "identifier" : "/documentation/VideoToolbox/VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Video Toolbox"
    ],
    "preciseIdentifier" : "c:@F@VTCompressionSessionEncodeFrame"
  },
  "title" : "VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:)"
}
-->

# VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:)

Presents frames to the compression session.

```
func VTCompressionSessionEncodeFrame(_ session: VTCompressionSession, imageBuffer: CVImageBuffer, presentationTimeStamp: CMTime, duration: CMTime, frameProperties: CFDictionary?, sourceFrameRefcon: UnsafeMutableRawPointer?, infoFlagsOut: UnsafeMutablePointer<VTEncodeInfoFlags>?) -> OSStatus
```

## Parameters

`session`

The compression session.

`imageBuffer`

A Core Video image buffer (<doc://com.apple.documentation/documentation/CoreVideo/CVImageBuffer>) containing a video frame to be compressed. The buffer must have a nonzero reference count.

`presentationTimeStamp`

The presentation timestamp for this frame, to be attached to the sample buffer. Each presentation timestamp passed to a session must be greater than the previous one.

`duration`

The presentation duration for this frame, to be attached to the sample buffer. If you do not have duration information, pass <doc://com.apple.documentation/documentation/CoreMedia/CMTime/invalid>.

`frameProperties`

Key/value pairs specifying additional properties for encoding this frame. Note that some session properties may also be changed between frames. Such changes affect subsequently encoded frames.

`sourceFrameRefcon`

Your reference value for the frame, which will be passed to the output callback function.

`infoFlagsOut`

A pointer to a `VTEncodeInfoFlags` to receive information about the encode operation.

    The [`asynchronous`](/documentation/VideoToolbox/VTEncodeInfoFlags/asynchronous)     bit may be set if the encode is (or was) running asynchronously.

    The [`frameDropped`](/documentation/VideoToolbox/VTEncodeInfoFlags/frameDropped)     bit may be set if the frame was dropped (synchronously).

    Pass     `NULL`     if you do not want to receive this information.

## Discussion

Encoded frames may or may not be output before the function returns. The client should not modify the pixel data after making this call. The session and/or encoder retains the image buffer as long as necessary.

---

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)