Skip to content

FilmCraft: An open-source, nonlinear video editor written by scratch in pure Rust

Captions: a TTML frame count that saturates the clock is rejected, not read as the end of time (#705 follow-up)

Brandon Thomas4cdb15466e4a
diff --git a/crates/captions/src/ttml.rs b/crates/captions/src/ttml.rs
index 1987ba328..6c98a7ff7 100644
--- a/crates/captions/src/ttml.rs
+++ b/crates/captions/src/ttml.rs
@@ -287,8 +287,12 @@ fn parse_time(s: &str, tm: Timing) -> Option<Tick> {
"f" => {
let n: i128 = vi.parse().ok()?;
let fd = tm.rate.tick_of(1).0 as i128;
- let whole = tm.rate.tick_of(n as i64).0 as i128;
- whole + decimal_ticks("0", vf, fd)?
+ let whole = tm.rate.tick_of(i64::try_from(n).ok()?);
+ // tick_of saturates; a saturated count overflowed rather than named a real time
+ if whole == Tick(i64::MAX) {
+ return None;
+ }
+ whole.0 as i128 + decimal_ticks("0", vf, fd)?
}
"t" => {
let n: i128 = vi.parse().ok()?;