GithubHelp home page GithubHelp logo

justm0rph3u5 / framerate-utils Goto Github PK

View Code? Open in Web Editor NEW

This project forked from netflix-skunkworks/framerate-utils

0.0 1.0 0.0 491 KB

Useful conversion utilities for working with video frame rate and display

TypeScript 100.00%

framerate-utils's Introduction

JavaScript Framerate Utils

Utilities for formatting and converting times to frame rates

Installation

npm install --save framerate-utils

Example 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:21

API

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_HOUR
  • SECONDS_PER_MINUTE
  • MILLISECONDS_PER_SECOND
  • TICKS_PER_SECOND

Functions

  • create(rate = 24, numerator = 1, denominator = 1, dropFrame = false) - Creates a new FrameRate object
  • secondsToSmpte(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.

framerate-utils's People

Contributors

tbranyen avatar andyswan avatar artemdanylenko avatar jamesplease avatar benduran avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.