简体   繁体   中英

What does a CMSampleBuffer's sample presentation time represent?

Our app is using AVFoundation to capture video, display, manipulate, and export the video using its sample buffers. I am trying to understand what the CMSampleBufferGetPresentationTimeStamp(_:) CMTime actually represents.

For example, when video capture begins, the first sample's presentation time is 93 hours and 5 minutes. I don't understand where this value comes from. Using the first sample's presentation time to start the AVAssetWriter session creates 93 hours of black frames before video playback begins.

It's based on a mach time, which means number of ticks from last reboot. You can create such CMTime with this code:

  mach_timebase_info_data_t timeInfo;
  mach_timebase_info(&timeInfo);
  CMTime time = CMTimeMake(mach_absolute_time() * timeInfo.numer / timeInfo.denom, 1000000000);

Or use this to get it already converted to number of seconds.
double seconds = CACurrentMediaTime();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM