4.3.0 • Published 3 years ago
framerate-utils v4.3.0
JavaScript Framerate Utils
Utilities for formatting and converting times to frame rates
Installation
npm install --save framerate-utilsExample usage
import { fromTag, secondsToSmpte } from 'framerate-utils';
const fr = fromTag('FPS_2397');
const seconds = 100;
const smpte = secondsToSmpte(fr, seconds);
console.log(smpte);
// output 00:01:39:21API
There are numerous functions and constants available for use. While looking
through methods if you come across a frameRate argument, you will need to
create one first and pass that in.
This FrameRate object has the following shape:
{
rate: number // The frame rate
numerator: number // The numerator of the frame rate multiplier
denominator: number // The denominator of the frame rate multiplier
dropFrame: bool // drop mode, true - NTSC drop frame, false - non drop frame
fps: number // The effective frame rate in frames per second (rate * (numerator/denominator))
}And can be created using the following code:
import { create } from 'framerate-utils';
const frameRate = create();Constants
SECONDS_PER_HOURSECONDS_PER_MINUTEMILLISECONDS_PER_SECONDTICKS_PER_SECOND
Functions
create(rate = 24, numerator = 1, denominator = 1, dropFrame = false)- Creates a new FrameRate objectsecondsToSmpte(frameRate, seconds)- Returns seconds converted to SMPTE time.smpteToSeconds(frameRate, smtpe)- Returns SMPTE time converted to seconds.smpteToMs- Returns SMPTE time converted to milliseconds.msToSmpte- Returns milliseconds converted to SMPTE time.
For all functions view the src/index.ts file.