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.

  2. Optionally, configure the session with your desired Compression Properties by calling VTSessionSetProperty or VTSessionSetProperties.

  3. Encode video frames using VTCompressionSessionEncodeFrame and receive the compressed video frames in the session's VTCompressionOutputCallback.

  4. To force the completion of some or all pending frames, call VTCompressionSessionCompleteFrames.

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

Topics

Creating Sessions

VTCompressionSessionCreate

Creates a session for compressing video frames.

Configuring Sessions

Compression Properties

Properties used to configure a VideoToolbox compression session.

Encoding Frames

VTCompressionSessionPrepareToEncodeFrames

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

VTCompressionSessionEncodeFrame

Presents frames to the compression session.

VTCompressionSessionEncodeFrameWithOutputHandler

Presents frames to the compression session and invokes the output callback when compression is complete.

VTCompressionSessionCompleteFrames

Forces the compression session to complete the encoding of frames.

Inspecting Sessions

VTCompressionSessionGetPixelBufferPool

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

VTCompressionSessionGetTypeID

Retrieves the Core Foundation type identifier for the compression session.

Performing Multipass Compression

VTCompressionSessionBeginPass

Marks the start of a specific compression pass.

VTCompressionSessionEndPass

Marks the end of a compression pass.

VTCompressionSessionGetTimeRangesForNextPass

Retrieves the time ranges for the next pass.

Ending Sessions

VTCompressionSessionInvalidate

Tears down a compression session.

Data Types

VTCompressionSessionRef

A reference to a VideoToolbox compression session.

VTCompressionOutputCallback

Prototype for the callback invoked when frame compression is complete.

VTCompressionOutputHandler

Prototype for the block invoked when frame compression is complete.

Constants

kVTVideoEncoderSpecification_EncoderID

A particular video encoder, specified by its ID string.