From 30a7d1923b360f993209426aff4d2ea76da794bc Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Fri, 7 Jul 2017 00:25:48 +0200 Subject: [PATCH] Fix a problem where we could wait for a very long time for the first frame on FFmpeg inputs. --- ffmpeg_capture.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ffmpeg_capture.cpp b/ffmpeg_capture.cpp index fb1b223..be27e6f 100644 --- a/ffmpeg_capture.cpp +++ b/ffmpeg_capture.cpp @@ -411,6 +411,9 @@ bool FFmpegCapture::play_video(const string &pathname) audio_format.num_channels = 8; for ( ;; ) { + if (last_pts == 0 && pts_origin == 0) { + pts_origin = frame->pts; + } next_frame_start = compute_frame_start(frame->pts, pts_origin, video_timebase, start, rate); video_frame.received_timestamp = next_frame_start; bool finished_wakeup = producer_thread_should_quit.sleep_until(next_frame_start); -- 2.39.2