diff --git a/src/main.rs b/src/main.rs index d326da5..7ff2904 100644 --- a/src/main.rs +++ b/src/main.rs @@ -298,10 +298,18 @@ impl Application for App { Message::Tick(_time) => { let start = Instant::now(); - match { + let video_frame_opt = { let mut video_frames = self.flags.video_frames_lock.lock().unwrap(); - video_frames.pop_front() - } { + //TODO: show frames at desired presentation time instead of clearing + let mut video_frame_opt = video_frames.pop_front(); + while video_frames.len() >= 4 { + if let Some(video_frame) = video_frames.pop_front() { + video_frame_opt = Some(video_frame); + } + } + video_frame_opt + }; + match video_frame_opt { Some(video_frame) => { let pts = video_frame.0.pts(); self.handle_opt = Some(video_frame.into_handle()); diff --git a/src/player.rs b/src/player.rs index f97205e..9fc986e 100644 --- a/src/player.rs +++ b/src/player.rs @@ -136,6 +136,7 @@ fn ffmpeg_thread>( .best(Type::Video) .ok_or(ffmpeg::Error::StreamNotFound)?; let video_stream_index = video_stream.index(); + let video_time_base = f64::from(video_stream.time_base()); let mut video_decoder = { let mut video_decoder_context = @@ -168,7 +169,9 @@ fn ffmpeg_thread>( let video_format = video_decoder.format(); let video_width = video_decoder.width(); let video_height = video_decoder.height(); - let (cpu_frame_tx, cpu_frame_rx) = mpsc::channel::