Code Monkey home page Code Monkey logo

subtitle-time's Introduction

subtitle-time

English Readme

专门处理字幕时间,可以处理 SRT, VTT 和 ASS 的时间.

安装

npm i subtitle-time

引入

const { SubtitleTime } = require('subtitle-time')

使用例子

秒 -> SRT

let t = new SubtitleTime(61, 'second');
t.to('srt'); // '00:01:01,000'

ASS -> 秒

let t = new SubtitleTime('0:01:15.50', 'ass');
t.to('second'); // 75.50

秒 -> VTT

let t = new SubtitleTime(61, 'second');
t.to('vtt'); // '00:01:01.000'

秒 -> ASS

let t = new SubtitleTime(61, 'second');
t.to('ass'); // '0:01:01.00'

SRT -> VTT

let t = new SubtitleTime('00:01:01,000', 'srt');
t.to('vtt'); // '00:01:01.000'

测试

npm test

这个库为什么存在?

  1. 我需要转换字幕的时间格式,比如把 5 (秒)转成 SRT 00:00:05,000
  2. dayjs, moment.js 等其他 JS 时间库用不了
  3. npm 上没有解决这个问题的工具

subtitle-time's People

Contributors

1c7 avatar dependabot[bot] avatar

Stargazers

 avatar

Watchers

 avatar  avatar  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.