Przeglądaj źródła

obs-ffmpeg: Use timestamps from video/audio frames

Instead of using system timestamps for playback, use the timestamps
directly from the video/audio data to ensure all the data is synced up
using the obs_source back-end.

I think the original misconception when this was written was that OBS
would not handle timestamp resets/loops, which isn't the case; it will
actually handle all timestamp resets and abnormalities.  It's always
best to use the obs_source back-end for all playback and syncing.
jp9000 10 lat temu
rodzic
commit
4d75c888a3
1 zmienionych plików z 2 dodań i 7 usunięć
  1. 2 7
      plugins/obs-ffmpeg/obs-ffmpeg-source.c

+ 2 - 7
plugins/obs-ffmpeg/obs-ffmpeg-source.c

@@ -244,8 +244,6 @@ static bool video_frame(struct ff_frame *frame, void *opaque)
 {
 	struct ffmpeg_source *s = opaque;
 	struct obs_source_frame obs_frame = {0};
-
-	double d_pts;
 	uint64_t pts;
 
 	// Media ended
@@ -255,8 +253,7 @@ static bool video_frame(struct ff_frame *frame, void *opaque)
 		return true;
 	}
 
-	d_pts = ff_get_sync_clock(&s->demuxer->clock) - frame->pts;
-	pts = os_gettime_ns() - (uint64_t)(d_pts * 1000000000.0L);
+	pts = (uint64_t)(frame->pts * 1000000000.0L);
 
 	obs_frame.timestamp = pts;
 	obs_frame.width = frame->frame->width;
@@ -279,15 +276,13 @@ static bool audio_frame(struct ff_frame *frame, void *opaque)
 
 	struct obs_source_audio audio_data = {0};
 
-	double d_pts;
 	uint64_t pts;
 
 	// Media ended
 	if (frame == NULL)
 		return true;
 
-	d_pts = ff_get_sync_clock(&s->demuxer->clock) - frame->pts;
-	pts = os_gettime_ns() - (uint64_t)(d_pts * 1000000000.0L);
+	pts = (uint64_t)(frame->pts * 1000000000.0L);
 
 	int channels = av_frame_get_channels(frame->frame);