Improve frame skipping
This commit is contained in:
parent
c726fca224
commit
da8c1f3df9
2 changed files with 25 additions and 11 deletions
|
|
@ -308,7 +308,9 @@ impl Application for App {
|
||||||
log::warn!("skipping video frame {:?}", old_frame.0.pts());
|
log::warn!("skipping video frame {:?}", old_frame.0.pts());
|
||||||
}
|
}
|
||||||
// Frame is ready to be shown
|
// Frame is ready to be shown
|
||||||
video_frame_opt = Some(video_frame)
|
video_frame_opt = Some(video_frame);
|
||||||
|
//TODO: allow skipping?
|
||||||
|
break;
|
||||||
} else {
|
} else {
|
||||||
// Put frame back and exit loop
|
// Put frame back and exit loop
|
||||||
video_frames.push_front(video_frame);
|
video_frames.push_front(video_frame);
|
||||||
|
|
|
||||||
|
|
@ -185,12 +185,18 @@ fn ffmpeg_thread<P: AsRef<Path>>(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let (mut cpu_frame, mut sync_time_opt) = cpu_frame_rx.recv().unwrap();
|
let mut recv_opt: Option<(Video, Option<Instant>)> = None;
|
||||||
while let Ok((extra_frame, time_opt)) = cpu_frame_rx.try_recv() {
|
while let Ok(recv) = cpu_frame_rx.try_recv() {
|
||||||
log::warn!("skipping cpu video frame at {:?}", cpu_frame.pts());
|
if let Some((old_frame, _)) = recv_opt {
|
||||||
cpu_frame = extra_frame;
|
//TODO: only skip if behind (frames come in weird timing from codecs)
|
||||||
sync_time_opt = time_opt;
|
log::warn!("skipping cpu video frame at {:?}", old_frame.pts());
|
||||||
|
}
|
||||||
|
recv_opt = Some(recv);
|
||||||
}
|
}
|
||||||
|
let (cpu_frame, sync_time_opt) = match recv_opt {
|
||||||
|
Some(some) => some,
|
||||||
|
None => cpu_frame_rx.recv().unwrap(),
|
||||||
|
};
|
||||||
let pts_opt = cpu_frame.pts();
|
let pts_opt = cpu_frame.pts();
|
||||||
|
|
||||||
// Start count after blocking recv
|
// Start count after blocking recv
|
||||||
|
|
@ -238,12 +244,18 @@ fn ffmpeg_thread<P: AsRef<Path>>(
|
||||||
.name("video_map_gpu_cpu".to_string())
|
.name("video_map_gpu_cpu".to_string())
|
||||||
.spawn(move || {
|
.spawn(move || {
|
||||||
loop {
|
loop {
|
||||||
let (mut gpu_frame, mut sync_time_opt) = gpu_frame_rx.recv().unwrap();
|
let mut recv_opt: Option<(Video, Option<Instant>)> = None;
|
||||||
while let Ok((extra_frame, time_opt)) = gpu_frame_rx.try_recv() {
|
while let Ok(recv) = gpu_frame_rx.try_recv() {
|
||||||
log::warn!("skipping gpu video frame at {:?}", gpu_frame.pts());
|
if let Some((old_frame, _)) = recv_opt {
|
||||||
gpu_frame = extra_frame;
|
//TODO: only skip if behind (frames come in weird timing from codecs)
|
||||||
sync_time_opt = time_opt;
|
log::warn!("skipping gpu video frame at {:?}", old_frame.pts());
|
||||||
|
}
|
||||||
|
recv_opt = Some(recv);
|
||||||
}
|
}
|
||||||
|
let (gpu_frame, sync_time_opt) = match recv_opt {
|
||||||
|
Some(some) => some,
|
||||||
|
None => gpu_frame_rx.recv().unwrap(),
|
||||||
|
};
|
||||||
let pts = gpu_frame.pts();
|
let pts = gpu_frame.pts();
|
||||||
|
|
||||||
// Start timer after blocking recv
|
// Start timer after blocking recv
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue