summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2026-05-22 13:11:04 +0000
committers-ol <s+removethis@s-ol.nu>2026-05-22 13:40:26 +0000
commit0f55c2011032a6ada8a66d2743efc88e229ff5a6 (patch)
tree45be24a59cd798ca57d3c9f23a02720f1ad75030 /src
parentfix SRGB fail (diff)
downloadwgsl-view-main.tar.gz
wgsl-view-main.zip
tsv-video-*: detect video length using format durationHEADmain
Diffstat (limited to 'src')
-rw-r--r--src/bin/tsv_video_buffer.rs1
-rw-r--r--src/bin/tsv_video_stream.rs7
-rw-r--r--src/ffmpeg.rs12
3 files changed, 10 insertions, 10 deletions
diff --git a/src/bin/tsv_video_buffer.rs b/src/bin/tsv_video_buffer.rs
index 3a244a8..1152193 100644
--- a/src/bin/tsv_video_buffer.rs
+++ b/src/bin/tsv_video_buffer.rs
@@ -50,6 +50,7 @@ fn main() {
}
let mut info = ffmpeg::probe_video(ff_args, max_frames);
+ log::info!("probe results: {:?}", info);
let num_frames = match (info.num_frames, max_frames) {
(Some(a), Some(b)) => u32::min(a, b),
(Some(a), None) => a,
diff --git a/src/bin/tsv_video_stream.rs b/src/bin/tsv_video_stream.rs
index c2db35c..2345c99 100644
--- a/src/bin/tsv_video_stream.rs
+++ b/src/bin/tsv_video_stream.rs
@@ -34,12 +34,7 @@ fn main() {
}
let info = ffmpeg::probe_video(ff_args, None);
- log::info!(
- "{}x{} @ {:.2}fps, tsv image: {name}",
- info.width,
- info.height,
- info.fps
- );
+ log::info!("probe results: {:?}", info);
let instance = gpu::create_instance();
let adapter = gpu::create_adapter(&instance, None);
diff --git a/src/ffmpeg.rs b/src/ffmpeg.rs
index fbfdc94..3c385c4 100644
--- a/src/ffmpeg.rs
+++ b/src/ffmpeg.rs
@@ -90,6 +90,7 @@ fn filter_probe_args(ff_args: &[String]) -> Vec<String> {
out
}
+#[derive(Debug)]
pub struct VideoInfo {
pub width: u32,
pub height: u32,
@@ -106,7 +107,7 @@ pub fn probe_video(ff_args: &[String], max_frames: Option<u32>) -> VideoInfo {
.args(["-select_streams", "v:0"])
.args([
"-show_entries",
- "stream=codec_tag_string,width,height,pix_fmt,r_frame_rate,nb_frames",
+ "stream=codec_tag_string,width,height,pix_fmt,r_frame_rate,nb_frames:format=duration",
])
.args(["-of", "csv=p=0"])
.args(&probe_args)
@@ -120,8 +121,8 @@ pub fn probe_video(ff_args: &[String], max_frames: Option<u32>) -> VideoInfo {
let stdout = String::from_utf8_lossy(&output.stdout);
let line = stdout.trim();
- let parts: Vec<&str> = line.split(',').collect();
- if parts.len() != 6 {
+ let parts: Vec<&str> = line.split(&[',', '\n']).collect();
+ if parts.len() != 7 {
panic!("unexpected ffprobe output: {line}");
}
@@ -137,7 +138,10 @@ pub fn probe_video(ff_args: &[String], max_frames: Option<u32>) -> VideoInfo {
} else {
parts[4].parse().expect("parse fps")
};
- let num_frames = parts[5].parse().ok().or(max_frames);
+ let num_frames = parts[5].parse::<u32>().ok().or(max_frames).or_else(|| {
+ let duration: f64 = parts[6].parse().ok()?;
+ Some((duration * fps) as u32)
+ });
VideoInfo {
width,