Przeglądaj źródła

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.
jp9000 11 lat temu
rodzic
commit
a07ebf44e6
1 zmienionych plików z 9 dodań i 1 usunięć
  1. 9 1
      libobs/media-io/video-io.c

+ 9 - 1
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);