I use VideoToolbox HW h.264 encoder with M1 MacBook for screen mirroring. I need run encoder with minimal delay mode.
I use these values as encoderSpecification kVTVideoEncoderSpecification_EnableHardwareAcceleratedVideoEncoder:true kVTCompressionPropertyKey_ProfileLevel:kVTProfileLevel_H264_Baseline_AutoLevel kVTCompressionPropertyKey_RealTime:true kVTCompressionPropertyKey_AllowFrameReordering:false
I set presentation timestamp with current time. In compressed callback, I got encoded frame with wrong order.
[13.930533]encode pts=...13.930511 [13.997633]encode pts=...13.997617 [14.013678]compress callback with pts=...13.997617 dts=...13.930511 [14.023443]compress callback with pts=...13.930511 dts=...13.997617
in[]:log time, pts:presentation timestamp, dts:decode timestamp
AllowFrameReordering is not working as I expected. If I need to set other property, please let me know.
I also does not like buffering 2 video frames. If you know settings for no buffering frame, please let me know.