Files
Sylpheed/crates/sylpheed-formats/examples/cue_unit_check.rs
Sylpheed RE agent 44dae8d387 re: cue times ARE seconds — and "the rate does not converge" was my error
Two things settled, one of them a correction of my own claim from the last
iteration.

The cue unit is verified rather than assumed. parse_timing computes mm*60+ss,
but only if the token really is mm:ss.cc, so I checked against an independent
oracle: the movies are on the disc and a cue must land inside its own movie.
66 English movies with subtitle tracks, 0 cues land after the movie ends.
Centiseconds would have overflowed essentially all 66. The seconds reading
stands and the verdicts built on it survive.

"The sample rate does not converge" does not. I reported implied rates of
39742 / 20563 / 23108 Hz as irreconcilable. They are not estimates of the
same quantity -- each is a ONE-SIDED BOUND. The audio must be at least as
long as the last cue, so samples/cue is an UPPER bound; it cannot outlast its
movie, so samples/movie is a LOWER bound. Intersecting:

  bank         samples    cue   movie   lower Hz   upper Hz
  VOICE_D_450   158967   4.00    9.30      17091      39742
  VOICE_D_451    76084   3.70    9.30       8180      20563
  VOICE_D_453   108608   4.70    9.30      11677      23108

  => 17091-20563 Hz, non-empty. A single rate IS consistent.

I had been comparing them as competing point estimates, which is why they
looked contradictory.

What is still open, and stated as such: that window contains no standard XMA
rate. The lower bound assumes a whole bank plays inside one movie, and each of
these banks is bound to 3-5 movie slots -- so if a bank holds several takes
the lower bound is void, leaving rate <= 20563, which 22050 nearly meets.
Next step recorded: establish whether a shared bank is one line or several.

Artifact: examples/cue_unit_check.rs.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01PMRJjbxLqZtsb5Vb7KunPE
2026-08-26 00:14:31 +00:00

60 lines
2.2 KiB
Rust

//! Are subtitle cue times really seconds?
//!
//! Every "audio missing" verdict in voice-bank-leading-region.md rests on
//! reading `track_voice_cues`' `f32` as seconds. `parse_timing` does compute
//! `mm*60 + ss` — but only if the token really is `mm:ss.cc`. The movies are on
//! the disc, so their true length is an independent oracle: a cue must land
//! INSIDE its own movie.
use std::process::Command;
use sylpheed_formats::{movie_subtitle, PakArchive};
fn movie_secs(path: &str) -> Option<f32> {
let out = Command::new("ffprobe")
.args([
"-v", "error", "-show_entries", "format=duration", "-of", "csv=p=0", path,
])
.output()
.ok()?;
String::from_utf8_lossy(&out.stdout).trim().parse().ok()
}
fn main() {
let disc = std::env::var("SYLPHEED_DISC").expect("set SYLPHEED_DISC");
let lang = PakArchive::open(format!("{disc}/dat/movie/eng.pak")).expect("eng.pak");
let mut checked = 0;
let mut over = 0;
let mut worst: Vec<(String, f32, f32)> = Vec::new();
let dir = format!("{disc}/dat/movie");
let Ok(rd) = std::fs::read_dir(&dir) else { return };
for e in rd.flatten() {
let p = e.path();
if p.extension().is_none_or(|x| x != "wmv") {
continue;
}
let base = p.file_stem().unwrap().to_string_lossy().to_string();
let cues = movie_subtitle::track_voice_cues(&lang, &base);
if cues.is_empty() {
continue;
}
let last = cues.iter().map(|(_, t)| *t).fold(0.0f32, f32::max);
let Some(secs) = movie_secs(&p.to_string_lossy()) else { continue };
checked += 1;
if last > secs {
over += 1;
worst.push((base, last, secs));
}
}
worst.sort_by(|a, b| (b.1 - b.2).partial_cmp(&(a.1 - a.2)).unwrap());
println!("movies with cues checked: {checked}");
println!("cues landing AFTER the movie ends: {over}");
for (m, last, secs) in worst.iter().take(8) {
println!(" {m:<28} last cue {last:>8.2}s movie {secs:>8.2}s");
}
println!(
"\nIf cues were centiseconds the last cue would be ~100x too big and \
essentially all {checked} would overflow."
);
}