CrystalComputerCorp / smpte-timecode

JavaScript library for operations with SMPTE timecodes
MIT License
68 stars 24 forks source link

Converting to seconds? #13

Closed pietrop closed 5 years ago

pietrop commented 5 years ago

Hello, Thanks for the great module!

I am using it to make an ADL (Audio Decision List) converter (aes31-adl-composer).

As far as I can tell, converting to seconds, is not part of the smpte-timecode module?

To convert to seconds I modified this example on stackoverflow.

const tcToSec = (timecode) =>{
    const hours   = timecode.hours * 60 * 60;
    const minutes = timecode.minutes * 60;
    const seconds = timecode.seconds;
    const frames  = timecode.frames *(1/timecode.frameRate);
    const totalTime = hours + minutes + seconds + frames;

    return totalTime;
};

But was wondering if there is already a way to do this as part of the module that I might have missed? or whether there might be interest in a PR to add the functionality?

m1tk4 commented 5 years ago

Wouldn't timecode.frameCount/timecode.frameRate be easier?