VideoToolBox 压缩

VTCompressionSession

管理输入视频数据压缩的会话。
压缩会话支持一系列视频frame的压缩。流程如下:

  • VTCompressionSessionCreate 创建session
  • 使用VTSessionSetProperty VTSessionSetProperties 配置sessions属性。
  • 使用VTCompressionSessionEncodeFrame编码视频frames,在VTCompressionOutputCallback 里接收压缩的视频frames.
  • VTComressionSessionCompleteFrames 表示没有视频数据输入了。
  • VTCompressionSessionInvalidate 结束session,释放内存。

  • 创建session

    1
    VTCompressionSessionCreate
  • 配置session

1
2
Compression Properties
Properties used to configure a VideoToolbox compression session.
  • 编码frame

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    VTCompressionSessionPrepareToEncodeFrames
    编码器在开始编码前进行资源分配,可选
    VTCompressionSessionEncodeFrame
    给session 提供frame
    VTCompressionSessionEncodeFrameWithOutputHandler
    给sesion 提供frame,压缩完成后调用callback。
    VTCompressionSessionCompleteFrames
    结束压缩session。
  • 检查session

    1
    2
    3
    4
    5
    VTCompressionSessionGetPixelBufferPool
    返回一个为压缩session提供理想资源pixel buffer的容器池。
    VTCompressionSessionGetTypeID
    Retrieves the Core Foundation type identifier for the compression session.
  • 多通道压缩

    1
    2
    3
    4
    5
    6
    7
    8
    VTCompressionSessionBeginPass
    标记一个压缩通道的开始
    VTCompressionSessionEndPass
    Marks the end of a compression pass.
    VTCompressionSessionGetTimeRangesForNextPass
    获取下一个通道的时间范围。
  • 结束Session

1
2
VTCompressionSessionInvalidate
Tears down a compression session.
  • 数据类型
1
2
3
4
5
6
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.
  • 枚举
    1
    VTCompressionSessionOptionFlags
1
2
3
4
5
VTEncodeInfoFlags
kVTEncodeInfo_Asynchronous
异步编码
kVTEncodeInfo_FrameDropped
编码的时候一个frame 被丢弃了。
文章目录
  1. 1. VTCompressionSession
|