Skip to content

Commit

Permalink
readme updates
Browse files Browse the repository at this point in the history
  • Loading branch information
Mtillmann committed Mar 8, 2024
1 parent 775a576 commit 78ea36d
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 34 deletions.
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
{
"name": "@mtillmann/chapters",
"version": "0.0.1",
"version": "0.0.2",
"description": "library that manages and converts chapters of multiple formats",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"files": [
"dist"
],
"scripts": {
"test": "jest",
"build": "rimraf dist && tsup",
"lint": "eslint src --ext .ts"
"lint": "eslint src --ext .ts",
"publishify": "npm run build && npm publish --access public"
},
"homepage": "https://github.com/Mtillmann/chapters",
"author": "Martin Tillmann<mtillmann@gmail.com>",
Expand Down
82 changes: 51 additions & 31 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,25 @@

Create, manage and convert chapters for 17 chapters formats:

| name | key | ext | info |
|------------------------------|----------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| Podcasting 2.0 Chapters | chaptersjson | `json` | [spec](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md) |
| FFMetadata | ffmpegdata | `txt` | [spec](https://ffmpeg.org/ffmpeg-formats.html#Metadata-1) |
| Matroska XML chapters | matroskaxml | `xml` | [spec](https://www.matroska.org/technical/chapters.html) |
| MKVToolNix mkvmerge XML | mkvmergexml | `xml` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
| MKVToolNix mkvmerge _simple_ | mkvmergesimple | `txt` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
| WebVTT Chapters | webvtt | `vtt` | [spec](https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API) |
| Youtube Chapter Syntax | youtube | `txt` | |
| FFMpegInfo | ffmpeginfo | `txt` | read only, used internally |
| PySceneDetect | pyscenedetect | `csv` | [project home](https://github.com/Breakthrough/PySceneDetect) |
| Vorbis Comment Format | vorbiscomment | `txt` | [spec](https://wiki.xiph.org/Chapter_Extension) |
| "Apple Chapters" | applechapters | `xml` | [source](https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#--chapter-string:~:text=CHAPTER03NAME%3Dchapter%2D3-,apple%20format,-(should%20be%20in)) |
| Shutter EDL | edl | `edl` | [source](https://github.com/paulpacifico/shutter-encoder/blob/f3d6bb6dfcd629861a0b0a50113bf4b062e1ba17/src/application/SceneDetection.java) |
| Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
| Podlove Simple Chapters JSON | podlovejson | `json` | [source](https://github.com/podlove/chapters#:~:text=org/%3E-,Encode%20to%20JSON,-iex%3E%20Chapters) |
| MP4Chaps | mp4chaps | `txt` | [source](https://github.com/podlove/chapters#:~:text=%3Achapters%3E-,Encode%20to%20mp4chaps,-iex%3E%20Chapters) |
| Apple HLS Chapters | applehls | `json` | [spec](https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters), partial support |
| Scenecut | scenecut | `json` | [source](https://github.com/slhck/scenecut-extractor#:~:text=cuts%20in%20JSON-,format,-%3A) |
| class | description | key | ext | info |
|-------------------------------------|------------------------------|----------------|--------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ChaptersJson | Podcasting 2.0 Chapters | chaptersjson | `json` | [spec](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md) |
| FFMetadata | FFMetadata | ffmpegdata | `txt` | [spec](https://ffmpeg.org/ffmpeg-formats.html#Metadata-1) |
| MatroskaXML | Matroska XML chapters | matroskaxml | `xml` | [spec](https://www.matroska.org/technical/chapters.html) |
| MKVMergeXML | MKVToolNix mkvmerge XML | mkvmergexml | `xml` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
| MKVMergeSimple | MKVToolNix mkvmerge _simple_ | mkvmergesimple | `txt` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
| WebVTT | WebVTT Chapters | webvtt | `vtt` | [spec](https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API) |
| Youtube | Youtube Chapter Syntax | youtube | `txt` | |
| FFMpegInfo | FFMpegInfo | ffmpeginfo | `txt` | read only, used internally |
| PySceneDetect | PySceneDetect | pyscenedetect | `csv` | [project home](https://github.com/Breakthrough/PySceneDetect) |
| VorbisComment | Vorbis Comment Format | vorbiscomment | `txt` | [spec](https://wiki.xiph.org/Chapter_Extension) |
| AppleChapters | "Apple Chapters" | applechapters | `xml` | [source](https://github.com/rigaya/NVEnc/blob/master/NVEncC_Options.en.md#--chapter-string:~:text=CHAPTER03NAME%3Dchapter%2D3-,apple%20format,-(should%20be%20in)) |
| ShutterEDL | Shutter EDL | edl | `edl` | [source](https://github.com/paulpacifico/shutter-encoder/blob/f3d6bb6dfcd629861a0b0a50113bf4b062e1ba17/src/application/SceneDetection.java) |
| PodloveSimpleChapters | Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
| PodloveJson | Podlove Simple Chapters JSON | podlovejson | `json` | [source](https://github.com/podlove/chapters#:~:text=org/%3E-,Encode%20to%20JSON,-iex%3E%20Chapters) |
| MP4Chaps | MP4Chaps | mp4chaps | `txt` | [source](https://github.com/podlove/chapters#:~:text=%3Achapters%3E-,Encode%20to%20mp4chaps,-iex%3E%20Chapters) |
| AppleHLS | Apple HLS Chapters | applehls | `json` | [spec](https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters), partial support |
| Scenecut | Scenecut | scenecut | `json` | [source](https://github.com/slhck/scenecut-extractor#:~:text=cuts%20in%20JSON-,format,-%3A) |

## Installation

Expand All @@ -31,18 +31,38 @@ Create, manage and convert chapters for 17 chapters formats:
## Usage

```javascript
import {ChapterJson} from '@mtillmann/chapters';

const chapters = new ChapterJson();
chapters.add({
startTime: 0,
title: 'Intro'
});
chapters.add({
startTime: 30,
title: 'Some Topic'
});
const json = chapters.toString();
import { ChaptersJson } from '@mtillmann/chapters';

const chapters = new ChaptersJson()
chapters.add({ startTime: 0, title: 'Intro' })
chapters.add({ startTime: 30, title: 'Some Topic' })
const json = chapters.toString()
```

## Autoformat

`Autoformat` is a helper that can be used to automatically detect the format of a given input and return the corresponding class,
key or a new instance of the detected class. It also provides a method to convert the input to a specific format.

```javascript
import { Autoformat } from '@mtillmann/chapters'
import { WebVTT } from '@mtillmann/chapters'

const content = '<podcasting 2.0 chapters.json>...'
const instance = Autoformat.detect(content) // returns an instance of ChaptersJson
const instance2 = Autoformat.from(content) // returns an instance of ChaptersJson

const key = Autoformat.detect(content, 'key') // returns 'chaptersjson'
const className = Autoformat.detect(content, 'class') // returns ChaptersJson

const webVttString = 'WEBVTT...';

const autodetectedWebVtt = Autoformat.detect(webVttString) // returns an instance of WebVTT

const fail = Autoformat.as('chaptersjson', webVttString) // throws an error

const vtt = Autoformat.as('webvtt', webVttString) // returns an instance of WebVTT
const vtt2 = Autoformat.as(WebVTT, webVttString) // returns an instance of WebVTT
```

## API
Expand Down
2 changes: 1 addition & 1 deletion tsup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default defineConfig({
format: ['esm'],
entry: ['src/index.ts'],
splitting: true,
sourcemap: true,
sourcemap: false,
clean: true,
dts: true,
})

0 comments on commit 78ea36d

Please sign in to comment.