VTCompressionSession

A session object that manages the compression of incoming video data.

Overview

A compression session supports the compression of a sequence of video frames. Here's the workflow:

  1. Create a compression session using VTCompressionSessionCreate(allocator:width:height:codecType:encoderSpecification:imageBufferAttributes:compressedDataAllocator:outputCallback:refcon:compressionSessionOut:).

  2. Optionally, configure the session with your desired Compression Properties by calling VTSessionSetProperty(_:key:value:) or VTSessionSetProperties(_:propertyDictionary:).

  3. Encode video frames using VTCompressionSessionEncodeFrame(_:imageBuffer:presentationTimeStamp:duration:frameProperties:sourceFrameRefcon:infoFlagsOut:) and receive the compressed video frames in the session's VTCompressionOutputCallback.

  4. To force the completion of some or all pending frames, call VTCompressionSessionCompleteFrames(_:untilPresentationTimeStamp:).

  5. When you finish with the compression session, call VTCompressionSessionInvalidate(_:) to invalidate it and CFRelease to free its memory.

Topics

Configuring Sessions

Compression Properties

Properties used to configure a VideoToolbox compression session.

Inspecting Sessions

func VTCompressionSessionGetPixelBufferPool(VTCompressionSession) -> CVPixelBufferPool?

Returns a pool that provides ideal source pixel buffers for a compression session.

func VTCompressionSessionGetTypeID() -> CFTypeID

Retrieves the Core Foundation type identifier for the compression session.

Ending Sessions

Data Types

class VTCompressionSession

A reference to a VideoToolbox compression session.

typealias VTCompressionOutputCallback

Prototype for the callback invoked when frame compression is complete.

typealias VTCompressionOutputHandler

Prototype for the block invoked when frame compression is complete.

Constants

let kVTVideoEncoderSpecification_EncoderID: CFString

A particular video encoder, specified by its ID string.