mirror of
https://github.com/obsproject/obs-studio.git
synced 2026-08-24 10:14:13 -05:00
mac-virtualcam: Prevent PTS rounding
All presentation time stamps are rounded to whole seconds during the conversion from nanoseconds to seconds, because of the immediate cast to `int64_t`. This results in the same presentation time stamp being send to consumers for a whole second. In previews/live streams this isn't super visible as last frame is often assumed to be the newest and the stream is updated. It's more problematic when recording since APIs like Apple's AVFoundation don't allow duplicate presentation time stamps or it can look like frames are produced in huge bursts once per second. In this PR `CMTimeMakeWithSeconds` is used instead of `CMTimeMake` to make sure the conversion is done correctly and simplify the calculation we have to do a little.
This commit is contained in:
committed by
Patrick Heyer
parent
ecaa5466cb
commit
970c284a65
@@ -21,9 +21,8 @@ CMSampleTimingInfo CMSampleTimingInfoForTimestamp(uint64_t timestampNanos,
|
||||
CMSampleTimingInfo timing;
|
||||
timing.duration =
|
||||
CMTimeMake(fpsDenominator * scale, fpsNumerator * scale);
|
||||
timing.presentationTimeStamp = CMTimeMake(
|
||||
((int64_t)(timestampNanos / (double)NSEC_PER_SEC) * scale),
|
||||
scale);
|
||||
timing.presentationTimeStamp = CMTimeMakeWithSeconds(
|
||||
timestampNanos / (double)NSEC_PER_SEC, scale);
|
||||
timing.decodeTimeStamp = kCMTimeInvalid;
|
||||
return timing;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user