opencinemac / vtc-rs

A SMPTE timecode library for Rust
MIT License
18 stars 3 forks source link

Parsing for drop frame timecodes can be incorrect #14

Open beauwright opened 5 months ago

beauwright commented 5 months ago

Here's a simple project to show what I've been running into with F29_97_DF and F59_94_DF rates.

use vtc::{rates, Timecode};

fn main() {
    let tc_1 = Timecode::with_frames("01:00:34;01", rates::F29_97_DF).unwrap();

    assert_eq!("01:00:34;01", tc_1.timecode());
}

Running this program results in:

assertion `left == right` failed
  left: "01:00:34;01"
 right: "01:00:34;02"

And if I use a rate of F59_94_DF instead:

assertion `left == right` failed
  left: "01:00:34;01"
 right: "01:00:34;03"
beauwright commented 5 months ago

I looked into this more and it looks like the problem lies in the drop_frame_adjustment function. I took my own stab at implementing that function based on the pseudocode from David Heidelberger and it seems to work correctly. Would you like me to submit a pull request?

peake100 commented 5 months ago

Sure! Go ahead and make a PR!