From a07ebf44e66938d2d2aee729e216ad8dc64195a8 Mon Sep 17 00:00:00 2001 From: jp9000 Date: Wed, 22 Oct 2014 15:11:08 -0700 Subject: [PATCH] media-io: Fix repeating video timestamps In video-io.c, video frames could skip, but what would happen is the frame's timestamp would repeat for the next frame, giving the next frame a non-monotonic timestamp, and then jump. This could mess up syncing slightly when the frame is finally given to an outputs. --- libobs/media-io/video-io.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libobs/media-io/video-io.c b/libobs/media-io/video-io.c index a48ce4cf6..fb5481352 100644 --- a/libobs/media-io/video-io.c +++ b/libobs/media-io/video-io.c @@ -61,6 +61,7 @@ struct video_output { volatile uint64_t cur_video_time; uint32_t skipped_frames; uint32_t total_frames; + uint64_t last_ts; bool initialized; @@ -120,8 +121,15 @@ static inline void video_output_cur_frame(struct video_output *video) struct video_input *input = video->inputs.array+i; struct video_data frame = video->cur_frame; - if (scale_video_output(input, &frame)) + if (scale_video_output(input, &frame)) { + if (frame.timestamp <= video->last_ts) + video->last_ts += video->frame_time; + else + video->last_ts = frame.timestamp; + + frame.timestamp = video->last_ts; input->callback(input->param, &frame); + } } pthread_mutex_unlock(&video->input_mutex);