---
title: "VTCompressionSessionPrepareToEncodeFrames(_:)"
framework: videotoolbox
role: symbol
role_heading: Function
path: "videotoolbox/vtcompressionsessionpreparetoencodeframes(_:)"
---

# VTCompressionSessionPrepareToEncodeFrames(_:)

Enables the encoder to perform any necessary resource allocation before the encoder begins encoding frames (optional).

## Declaration

```swift
func VTCompressionSessionPrepareToEncodeFrames(_ session: VTCompressionSession) -> OSStatus
```

## Parameters

- `session`: The compression session.

## Discussion

Discussion If this function isn’t called, any necessary resources are allocated on the first VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:) call. Subsequent calls to this function have no effect.

## See Also

### Encoding Frames

- [VTCompressionSessionGetPixelBufferPool(_:)](videotoolbox/vtcompressionsessiongetpixelbufferpool(_:).md)
- [VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:)](videotoolbox/vtcompressionsessionencodeframe(_:imagebuffer:presentationtimestamp:duration:frameproperties:sourceframerefcon:infoflagsout:).md)
- [VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:infoFlagsOut:outputHandler:)](videotoolbox/vtcompressionsessionencodeframe(_:imagebuffer:presentationtimestamp:duration:frameproperties:infoflagsout:outputhandler:).md)
- [VTCompressionSessionCompleteFrames(_:untilPresentationTimeStamp:)](videotoolbox/vtcompressionsessioncompleteframes(_:untilpresentationtimestamp:).md)
