Set rate at which AVSampleBufferDisplayLayer renders sample buffers

前端 未结 3 1004
天涯浪人
天涯浪人 2021-01-06 20:58

I am using an AVSampleBufferDisplayLayer to display CMSampleBuffers which are coming over a network connection in the h.264 format. Video playback is smooth and working corr

3条回答
  •  旧时难觅i
    2021-01-06 21:35

    Hit with the same issue, managed to play several streams one after another without lags with following timing in CMSampleBufferCreate creation

    CMSampleTimingInfo timingdata ={
     .presentationTimeStamp = CMTimeMakeWithSeconds(self.frame0time+(1/self.frameFPS)*self.frameActive, 1000),
     .duration =  CMTimeMakeWithSeconds(1/self.frameFPS, 1000),
     .decodeTimeStamp = kCMTimeInvalid
    };
    

    No need to use kCMSampleAttachmentKey_DisplayImmediately with this approach, you just have to self.frameActive++ on every Iframe and BFrame and make self.frame0time = CACurrentMediaTime(); on first frame

提交回复
热议问题