Skip to content

Commit

Permalink
Fix variable-framerate videos in standalone app
Browse files Browse the repository at this point in the history
  • Loading branch information
valadaptive committed Oct 21, 2024
1 parent 52bf32c commit 4ef10b0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion crates/gui/src/app/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1381,7 +1381,9 @@ impl NtscApp {
.structure(0)?
.get::<gstreamer::Fraction>("framerate")
.ok()?;
Some(framerate)

// If the framerate is 0, treat it like it's absent
(framerate.numer() != 0).then_some(framerate)
})();

egui::TopBottomPanel::top("video_info")
Expand Down
15 changes: 13 additions & 2 deletions crates/gui/src/gst_utils/pipeline_utils.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use super::{gstreamer_error::GstreamerError, scale_from_caps};
use gstreamer::{element_error, element_warning, glib, prelude::*};
use gstreamer::{element_error, element_warning, glib, prelude::*, query::Duration};
use gstreamer_video::VideoInterlaceMode;
use log::debug;
use std::{
Expand Down Expand Up @@ -220,11 +220,22 @@ pub fn create_pipeline<
))
});

let is_still_image = match framerate {
let mut q = Duration::new(gstreamer::Format::Time);
let _ = src_pad.query(q.query_mut());
let src_duration = q.result();
let has_duration = src_duration.is_some();

let has_zero_framerate = match framerate {
Some(framerate) => framerate.numer() == 0,
None => false,
};

// TODO: Videos with a variable framerate have a framerate of 0, so we also check if the input
// has a defined duration (see https://github.com/valadaptive/ntsc-rs/issues/8). Since we do so,
// is it still necessary to have *both* checks? Are there some videos that are not still images
// but still have no duration?
let is_still_image = has_zero_framerate && !has_duration;

let video_sink = video_sink(
&pipeline,
VideoElemMetadata {
Expand Down

0 comments on commit 4ef10b0

Please sign in to comment.