---
title: VTCompressionSession
framework: videotoolbox
role: collectionGroup
role_heading: API Collection
path: videotoolbox/vtcompressionsession-api-collection
---

# VTCompressionSession

An object that compresses video data.

## Overview

Overview A compression session supports the compression of a sequence of video frames. Here’s the workflow: Create a compression session using VTCompressionSessionCreate(allocator:width:height:codecType:encoderSpecification:imageBufferAttributes:compressedDataAllocator:outputCallback:refcon:compressionSessionOut:). Optionally, configure the session with your desired Compression Properties by calling VTSessionSetProperty(_:key:value:) or VTSessionSetProperties(_:propertyDictionary:). Encode video frames using VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:) and receive the compressed video frames in the session’s VTCompressionOutputCallback. To force the completion of some or all pending frames, call VTCompressionSessionCompleteFrames(_:untilPresentationTimeStamp:). When you finish with the compression session, call VTCompressionSessionInvalidate(_:) to invalidate it and CFRelease to free its memory.

## Topics

### Creating a Session

- [VTCompressionSessionCreate(allocator:width:height:codecType:encoderSpecification:imageBufferAttributes:compressedDataAllocator:outputCallback:refcon:compressionSessionOut:)](videotoolbox/vtcompressionsessioncreate(allocator:width:height:codectype:encoderspecification:imagebufferattributes:compresseddataallocator:outputcallback:refcon:compressionsessionout:).md)

### Configuring a Session

- [Compression Properties](videotoolbox/compression-properties.md)

### Encoding Frames

- [VTCompressionSessionGetPixelBufferPool(_:)](videotoolbox/vtcompressionsessiongetpixelbufferpool(_:).md)
- [VTCompressionSessionPrepareToEncodeFrames(_:)](videotoolbox/vtcompressionsessionpreparetoencodeframes(_:).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)

### Encoding Multi-Image Frames

- [VTIsStereoMVHEVCEncodeSupported()](videotoolbox/vtisstereomvhevcencodesupported().md)
- [VTCompressionSessionEncodeMultiImageFrame(_:taggedBuffers:presentationTimeStamp:duration:frameProperties:infoFlagsOut:outputHandler:)](videotoolbox/vtcompressionsessionencodemultiimageframe(_:taggedbuffers:presentationtimestamp:duration:frameproperties:infoflagsout:outputhandler:).md)

### Performing Multiple Passes

- [VTCompressionSessionBeginPass(_:flags:_:)](videotoolbox/vtcompressionsessionbeginpass(_:flags:_:).md)
- [VTCompressionSessionEndPass(_:furtherPassesRequestedOut:_:)](videotoolbox/vtcompressionsessionendpass(_:furtherpassesrequestedout:_:).md)
- [VTCompressionSessionGetTimeRangesForNextPass(_:timeRangeCountOut:timeRangeArrayOut:)](videotoolbox/vtcompressionsessiongettimerangesfornextpass(_:timerangecountout:timerangearrayout:).md)

### Invalidating a Session

- [VTCompressionSessionInvalidate(_:)](videotoolbox/vtcompressionsessioninvalidate(_:).md)

### Accessing the Type Identifier

- [VTCompressionSessionGetTypeID()](videotoolbox/vtcompressionsessiongettypeid().md)

### Data Types

- [VTCompressionSession](videotoolbox/vtcompressionsession.md)
- [VTEncodeInfoFlags](videotoolbox/vtencodeinfoflags.md)

## See Also

### Compression

- [Encoding video for low-latency conferencing](videotoolbox/encoding-video-for-low-latency-conferencing.md)
- [Encoding video for live streaming](videotoolbox/encoding-video-for-live-streaming.md)
- [Encoding video for offline transcoding](videotoolbox/encoding-video-for-offline-transcoding.md)
- [VTDecompressionSession](videotoolbox/vtdecompressionsession-api-collection.md)
- [VTFrameSilo](videotoolbox/vtframesilo-api-collection.md)
- [VTMultiPassStorage](videotoolbox/vtmultipassstorage-api-collection.md)
