@mtillmann/chapters 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -0
- package/package.json +62 -62
- package/readme.md +197 -196
package/dist/index.d.ts
CHANGED
|
@@ -294,4 +294,4 @@ declare namespace util {
|
|
|
294
294
|
export { util_Float as Float, util_Floats as Floats, util_Int as Int, util_Ints as Ints, util_NPTToSeconds as NPTToSeconds, util_enforceMilliseconds as enforceMilliseconds, util_escapeRegExpCharacters as escapeRegExpCharacters, util_formatBytes as formatBytes, util_hash as hash, util_indenter as indenter, util_secondsToNPT as secondsToNPT, util_secondsToTimestamp as secondsToTimestamp, util_stringToLines as stringToLines, util_timestampToSeconds as timestampToSeconds, util_toSeconds as toSeconds, util_zeroPad as zeroPad };
|
|
295
295
|
}
|
|
296
296
|
|
|
297
|
-
export { AppleChapters, AppleHLS, AutoFormat, ChaptersJson, FFMetadata, FFMpegInfo, MKVMergeSimple, MKVMergeXML, MP4Chaps, MatroskaXML, PodloveJson, PodloveSimpleChapters, PySceneDetect, Scenecut, ShutterEDL, util as Util, VorbisComment, WebVTT, Youtube };
|
|
297
|
+
export { AppleChapters, AppleHLS, AutoFormat, type Chapter, ChaptersJson, FFMetadata, FFMpegInfo, MKVMergeSimple, MKVMergeXML, MP4Chaps, MatroskaXML, type MediaItem, type MediaItemMeta, PodloveJson, PodloveSimpleChapters, PySceneDetect, Scenecut, ShutterEDL, util as Util, VorbisComment, WebVTT, Youtube };
|
package/dist/index.js
CHANGED
|
@@ -762,6 +762,7 @@ var MKVMergeXML = class extends MatroskaXML {
|
|
|
762
762
|
mimeType = "text/xml";
|
|
763
763
|
chapterStringNodeName = "ChapterString";
|
|
764
764
|
inputTimeToSeconds(string) {
|
|
765
|
+
string = string.replace(/\.(\d{3}).*$/, ".$1");
|
|
765
766
|
return timestampToSeconds(string);
|
|
766
767
|
}
|
|
767
768
|
secondsToOutputTime(seconds) {
|
package/package.json
CHANGED
|
@@ -1,62 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@mtillmann/chapters",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "library that manages and converts chapters of multiple formats",
|
|
5
|
-
"main": "dist/index.js",
|
|
6
|
-
"types": "dist/index.d.ts",
|
|
7
|
-
"type": "module",
|
|
8
|
-
"files": [
|
|
9
|
-
"dist"
|
|
10
|
-
],
|
|
11
|
-
"scripts": {
|
|
12
|
-
"test": "jest",
|
|
13
|
-
"build": "rimraf dist && tsup",
|
|
14
|
-
"lint": "eslint src --ext .ts",
|
|
15
|
-
"publishify": "npm run build && npm publish --access public"
|
|
16
|
-
},
|
|
17
|
-
"homepage": "https://github.com/Mtillmann/chapters",
|
|
18
|
-
"author": "Martin Tillmann<mtillmann@gmail.com>",
|
|
19
|
-
"bugs": {
|
|
20
|
-
"url": "https://github.com/Mtillmann/chapters/issues"
|
|
21
|
-
},
|
|
22
|
-
"keywords": [
|
|
23
|
-
"podcast",
|
|
24
|
-
"ffmpeg",
|
|
25
|
-
"chapters",
|
|
26
|
-
"youtube",
|
|
27
|
-
"mkvmerge",
|
|
28
|
-
"matroska",
|
|
29
|
-
"webvtt",
|
|
30
|
-
"pyscenedetect",
|
|
31
|
-
"vorbis",
|
|
32
|
-
"apple-chapters",
|
|
33
|
-
"podlove",
|
|
34
|
-
"podcast-chapters",
|
|
35
|
-
"edl",
|
|
36
|
-
"hls",
|
|
37
|
-
"scenecut"],
|
|
38
|
-
"license": "MIT",
|
|
39
|
-
"devDependencies": {
|
|
40
|
-
"@babel/core": "^7.24.0",
|
|
41
|
-
"@babel/preset-env": "^7.24.0",
|
|
42
|
-
"@types/jest": "^29.5.12",
|
|
43
|
-
"@types/jsdom": "^21.1.6",
|
|
44
|
-
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
45
|
-
"babel-jest": "^29.7.0",
|
|
46
|
-
"eslint": "^8.57.0",
|
|
47
|
-
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
48
|
-
"eslint-plugin-import": "^2.29.1",
|
|
49
|
-
"eslint-plugin-n": "^16.6.2",
|
|
50
|
-
"eslint-plugin-promise": "^6.1.1",
|
|
51
|
-
"jest": "^29.7.0",
|
|
52
|
-
"jest-environment-jsdom": "^29.7.0",
|
|
53
|
-
"rimraf": "^5.0.5",
|
|
54
|
-
"ts-jest": "^29.1.2",
|
|
55
|
-
"tsup": "^8.0.2",
|
|
56
|
-
"typescript": "^5.3.3"
|
|
57
|
-
},
|
|
58
|
-
"dependencies": {
|
|
59
|
-
"filenamify": "^6.0.0",
|
|
60
|
-
"jsdom": "^24.0.0"
|
|
61
|
-
}
|
|
62
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@mtillmann/chapters",
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "library that manages and converts chapters of multiple formats",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"type": "module",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist"
|
|
10
|
+
],
|
|
11
|
+
"scripts": {
|
|
12
|
+
"test": "jest",
|
|
13
|
+
"build": "rimraf dist && tsup",
|
|
14
|
+
"lint": "eslint src --ext .ts",
|
|
15
|
+
"publishify": "npm run build && npm publish --access public"
|
|
16
|
+
},
|
|
17
|
+
"homepage": "https://github.com/Mtillmann/chapters",
|
|
18
|
+
"author": "Martin Tillmann<mtillmann@gmail.com>",
|
|
19
|
+
"bugs": {
|
|
20
|
+
"url": "https://github.com/Mtillmann/chapters/issues"
|
|
21
|
+
},
|
|
22
|
+
"keywords": [
|
|
23
|
+
"podcast",
|
|
24
|
+
"ffmpeg",
|
|
25
|
+
"chapters",
|
|
26
|
+
"youtube",
|
|
27
|
+
"mkvmerge",
|
|
28
|
+
"matroska",
|
|
29
|
+
"webvtt",
|
|
30
|
+
"pyscenedetect",
|
|
31
|
+
"vorbis",
|
|
32
|
+
"apple-chapters",
|
|
33
|
+
"podlove",
|
|
34
|
+
"podcast-chapters",
|
|
35
|
+
"edl",
|
|
36
|
+
"hls",
|
|
37
|
+
"scenecut"],
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@babel/core": "^7.24.0",
|
|
41
|
+
"@babel/preset-env": "^7.24.0",
|
|
42
|
+
"@types/jest": "^29.5.12",
|
|
43
|
+
"@types/jsdom": "^21.1.6",
|
|
44
|
+
"@typescript-eslint/eslint-plugin": "^6.21.0",
|
|
45
|
+
"babel-jest": "^29.7.0",
|
|
46
|
+
"eslint": "^8.57.0",
|
|
47
|
+
"eslint-config-standard-with-typescript": "^43.0.1",
|
|
48
|
+
"eslint-plugin-import": "^2.29.1",
|
|
49
|
+
"eslint-plugin-n": "^16.6.2",
|
|
50
|
+
"eslint-plugin-promise": "^6.1.1",
|
|
51
|
+
"jest": "^29.7.0",
|
|
52
|
+
"jest-environment-jsdom": "^29.7.0",
|
|
53
|
+
"rimraf": "^5.0.5",
|
|
54
|
+
"ts-jest": "^29.1.2",
|
|
55
|
+
"tsup": "^8.0.2",
|
|
56
|
+
"typescript": "^5.3.3"
|
|
57
|
+
},
|
|
58
|
+
"dependencies": {
|
|
59
|
+
"filenamify": "^6.0.0",
|
|
60
|
+
"jsdom": "^24.0.0"
|
|
61
|
+
}
|
|
62
|
+
}
|
package/readme.md
CHANGED
|
@@ -1,196 +1,197 @@
|
|
|
1
|
-

|
|
2
|
-
|
|
3
|
-
[](https://badge.fury.io/js/@mtillmann%2Fchapters)
|
|
4
|
-
|
|
5
|
-
# chapters
|
|
6
|
-
|
|
7
|
-
This is the core library of the [chaptertool](https://github.com/Mtillmann/chaptertool) project and provides the functionality to handle the formats below.
|
|
8
|
-
|
|
9
|
-
[Click here to open the web GUI](https://mtillmann.github.io/chaptertool) or go install chaptertool locally for CLI use.
|
|
10
|
-
|
|
11
|
-
## Supported formats
|
|
12
|
-
|
|
13
|
-
| class
|
|
14
|
-
|
|
15
|
-
| ChaptersJson
|
|
16
|
-
| FFMetadata
|
|
17
|
-
| MatroskaXML
|
|
18
|
-
| MKVMergeXML
|
|
19
|
-
| MKVMergeSimple
|
|
20
|
-
| WebVTT
|
|
21
|
-
| Youtube
|
|
22
|
-
| FFMpegInfo
|
|
23
|
-
| PySceneDetect
|
|
24
|
-
| VorbisComment
|
|
25
|
-
| AppleChapters
|
|
26
|
-
| ShutterEDL
|
|
27
|
-
| PodloveSimpleChapters | Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
|
|
28
|
-
| PodloveJson
|
|
29
|
-
| MP4Chaps
|
|
30
|
-
| AppleHLS
|
|
31
|
-
| Scenecut
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
chapters
|
|
44
|
-
chapters.add({ startTime:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
import {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
const
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
|
168
|
-
| `
|
|
169
|
-
| `
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
|
182
|
-
| `
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
|
189
|
-
| `
|
|
190
|
-
| `
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
>
|
|
195
|
-
|
|
196
|
-
|
|
1
|
+

|
|
2
|
+
|
|
3
|
+
[](https://badge.fury.io/js/@mtillmann%2Fchapters)
|
|
4
|
+
|
|
5
|
+
# chapters
|
|
6
|
+
|
|
7
|
+
This is the core library of the [chaptertool](https://github.com/Mtillmann/chaptertool) project and provides the functionality to handle the formats below.
|
|
8
|
+
|
|
9
|
+
[Click here to open the web GUI](https://mtillmann.github.io/chaptertool) or go install chaptertool locally for CLI use.
|
|
10
|
+
|
|
11
|
+
## Supported formats
|
|
12
|
+
|
|
13
|
+
| class | description | key | ext | info |
|
|
14
|
+
| --------------------- | ---------------------------- | -------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
15
|
+
| ChaptersJson | Podcasting 2.0 Chapters | chaptersjson | `json` | [spec](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md) |
|
|
16
|
+
| FFMetadata | FFMetadata | ffmpegdata | `txt` | [spec](https://ffmpeg.org/ffmpeg-formats.html#Metadata-1) |
|
|
17
|
+
| MatroskaXML | Matroska XML chapters | matroskaxml | `xml` | [spec](https://www.matroska.org/technical/chapters.html) |
|
|
18
|
+
| MKVMergeXML | MKVToolNix mkvmerge XML | mkvmergexml | `xml` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
|
|
19
|
+
| MKVMergeSimple | MKVToolNix mkvmerge _simple_ | mkvmergesimple | `txt` | [spec](https://mkvtoolnix.download/doc/mkvmerge.html#mkvmerge.chapters) |
|
|
20
|
+
| WebVTT | WebVTT Chapters | webvtt | `vtt` | [spec](https://developer.mozilla.org/en-US/docs/Web/API/WebVTT_API) |
|
|
21
|
+
| Youtube | Youtube Chapter Syntax | youtube | `txt` | |
|
|
22
|
+
| FFMpegInfo | FFMpegInfo | ffmpeginfo | `txt` | read only, used internally |
|
|
23
|
+
| PySceneDetect | PySceneDetect | pyscenedetect | `csv` | [project home](https://github.com/Breakthrough/PySceneDetect) |
|
|
24
|
+
| VorbisComment | Vorbis Comment Format | vorbiscomment | `txt` | [spec](https://wiki.xiph.org/Chapter_Extension) |
|
|
25
|
+
| 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)) |
|
|
26
|
+
| ShutterEDL | Shutter EDL | edl | `edl` | [source](https://github.com/paulpacifico/shutter-encoder/blob/f3d6bb6dfcd629861a0b0a50113bf4b062e1ba17/src/application/SceneDetection.java) |
|
|
27
|
+
| PodloveSimpleChapters | Podlove Simple Chapters | psc | `xml` | [spec](https://podlove.org/simple-chapters/) |
|
|
28
|
+
| PodloveJson | Podlove Simple Chapters JSON | podlovejson | `json` | [source](https://github.com/podlove/chapters#:~:text=org/%3E-,Encode%20to%20JSON,-iex%3E%20Chapters) |
|
|
29
|
+
| MP4Chaps | MP4Chaps | mp4chaps | `txt` | [source](https://github.com/podlove/chapters#:~:text=%3Achapters%3E-,Encode%20to%20mp4chaps,-iex%3E%20Chapters) |
|
|
30
|
+
| AppleHLS | Apple HLS Chapters | applehls | `json` | [spec](https://developer.apple.com/documentation/http-live-streaming/providing-javascript-object-notation-json-chapters), partial support |
|
|
31
|
+
| Scenecut | Scenecut format | scenecut | `json` | [source](https://github.com/slhck/scenecut-extractor#:~:text=cuts%20in%20JSON-,format,-%3A) |
|
|
32
|
+
| Audible | Audible Chapter Format | audible | `json` | [source](./audible-chapter-spec.md) |
|
|
33
|
+
|
|
34
|
+
## Installation
|
|
35
|
+
|
|
36
|
+
`npm i @mtillmann/chapters`
|
|
37
|
+
|
|
38
|
+
## Usage
|
|
39
|
+
|
|
40
|
+
```javascript
|
|
41
|
+
import { ChaptersJson } from '@mtillmann/chapters';
|
|
42
|
+
|
|
43
|
+
const chapters = new ChaptersJson()
|
|
44
|
+
chapters.add({ startTime: 0, title: 'Intro' })
|
|
45
|
+
chapters.add({ startTime: 30, title: 'Some Topic' })
|
|
46
|
+
const json = chapters.toString()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Autoformat
|
|
50
|
+
|
|
51
|
+
`Autoformat` is a helper that can be used to automatically detect the format of a given input and return the corresponding class,
|
|
52
|
+
key or a new instance of the detected class. It also provides a method to convert the input to a specific format.
|
|
53
|
+
|
|
54
|
+
```javascript
|
|
55
|
+
import { Autoformat } from '@mtillmann/chapters'
|
|
56
|
+
import { WebVTT } from '@mtillmann/chapters'
|
|
57
|
+
|
|
58
|
+
const content = '<podcasting 2.0 chapters.json>...'
|
|
59
|
+
const instance = Autoformat.detect(content) // returns an instance of ChaptersJson
|
|
60
|
+
const instance2 = Autoformat.from(content) // returns an instance of ChaptersJson
|
|
61
|
+
|
|
62
|
+
const key = Autoformat.detect(content, 'key') // returns 'chaptersjson'
|
|
63
|
+
const className = Autoformat.detect(content, 'class') // returns ChaptersJson
|
|
64
|
+
|
|
65
|
+
const webVttString = 'WEBVTT...';
|
|
66
|
+
|
|
67
|
+
const autodetectedWebVtt = Autoformat.detect(webVttString) // returns an instance of WebVTT
|
|
68
|
+
|
|
69
|
+
const fail = Autoformat.as('chaptersjson', webVttString) // throws an error
|
|
70
|
+
|
|
71
|
+
const vtt = Autoformat.as('webvtt', webVttString) // returns an instance of WebVTT
|
|
72
|
+
const vtt2 = Autoformat.as(WebVTT, webVttString) // returns an instance of WebVTT
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## API
|
|
76
|
+
|
|
77
|
+
All formats support the following methods:
|
|
78
|
+
|
|
79
|
+
### `constructor (duration: number = 3600)`
|
|
80
|
+
|
|
81
|
+
Creates a new instance of the class, optionally with a duration in seconds.
|
|
82
|
+
|
|
83
|
+
```javascript
|
|
84
|
+
const chapters = (new ChaptersJson(3600)).from(input)
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
> the constructor will not accept any input due to javascript's order of initialization which prevents the parse method
|
|
88
|
+
> from having access to cerain locally defined properties and methods.
|
|
89
|
+
|
|
90
|
+
### `static create (input?: string | MediaItem): MediaItem`
|
|
91
|
+
|
|
92
|
+
Creates a new media item. This is the suggested way to create a media item from a string:
|
|
93
|
+
|
|
94
|
+
```javascript
|
|
95
|
+
const chapters = MatroskaXML.create(input)
|
|
96
|
+
// chapters is now an instance of MatroskaXML
|
|
97
|
+
|
|
98
|
+
const chapterString = WebVTT.create(chapters).toString()
|
|
99
|
+
// chapterString is now a string representation of the chapters
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### `from (input?: string | MediaItem): MediaItem`
|
|
103
|
+
|
|
104
|
+
Populates the media item's chapters from the given input.
|
|
105
|
+
|
|
106
|
+
### `to (className: any): MediaItem`
|
|
107
|
+
|
|
108
|
+
Converts the media item to another format.
|
|
109
|
+
|
|
110
|
+
### `add (chapter: Chapter): void`
|
|
111
|
+
|
|
112
|
+
Adds a chapter.
|
|
113
|
+
|
|
114
|
+
### `addChapterAt (index: number, chapter: object = {}): number`
|
|
115
|
+
|
|
116
|
+
Adds a chapter at the given index.
|
|
117
|
+
|
|
118
|
+
### `addChapterAtTime (time: number | string, chapter: object = {}): boolean`
|
|
119
|
+
|
|
120
|
+
Adds a chapter at the given time.
|
|
121
|
+
|
|
122
|
+
### `remove (index: number): void`
|
|
123
|
+
|
|
124
|
+
Removes the chapter at the given index.
|
|
125
|
+
|
|
126
|
+
### `bump (keepDuration: boolean = false): void`
|
|
127
|
+
|
|
128
|
+
Updates the chapters and duration. Called automatically after adding or removing chapters.
|
|
129
|
+
|
|
130
|
+
### `endTime (index: number): number`
|
|
131
|
+
|
|
132
|
+
Returns the end time for the chapter at the given index.
|
|
133
|
+
|
|
134
|
+
### `expandFirstToStart (): void`
|
|
135
|
+
|
|
136
|
+
Expands the first chapter to start at 0.
|
|
137
|
+
|
|
138
|
+
### `applyChapterMinLength (seconds: number): object`
|
|
139
|
+
|
|
140
|
+
Applies a minimum length to the chapters.
|
|
141
|
+
|
|
142
|
+
### `chapterExistsAtStartTime (time: number): boolean`
|
|
143
|
+
|
|
144
|
+
Checks if a chapter exists at the given start time.
|
|
145
|
+
|
|
146
|
+
### `updateChapterStartTime (index: number, startTime: number | string): number | 'timeInUse'`
|
|
147
|
+
|
|
148
|
+
Updates the start time for the chapter at the given index.
|
|
149
|
+
|
|
150
|
+
### `chapterIndexFromStartTime (startTime: number | string): number`
|
|
151
|
+
|
|
152
|
+
Returns the index of the chapter with the given start time.
|
|
153
|
+
|
|
154
|
+
### `chapterIndexFromTime (time: number | string): null | number`
|
|
155
|
+
|
|
156
|
+
Returns the index of the chapter at the given time.
|
|
157
|
+
|
|
158
|
+
### `toString([pretty: boolean][, options: object]): string`
|
|
159
|
+
|
|
160
|
+
Convert the chapters to a string.
|
|
161
|
+
If `pretty` is `true`, the output will be formatted for better readability. Only supported by `json` and `xml` formats.
|
|
162
|
+
Some formats support additional options:
|
|
163
|
+
|
|
164
|
+
#### ChapterJson toString() options
|
|
165
|
+
|
|
166
|
+
| option | type | default | description |
|
|
167
|
+
| ------------------- | --------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
168
|
+
| `imagePrefix` | `string` | `''` | Prefix for image URLs |
|
|
169
|
+
| `writeRedundantToc` | `boolean` | `false` | Write [redundant](https://github.com/Podcastindex-org/podcast-namespace/blob/main/chapters/jsonChapters.md#:~:text=or%20not%20present%20at%20all) TOC attributes |
|
|
170
|
+
| `writeEndTimes` | `boolean` | `false` | Write end times |
|
|
171
|
+
|
|
172
|
+
#### AppleChapters toString() options
|
|
173
|
+
|
|
174
|
+
| option | type | default | description |
|
|
175
|
+
| --------------- | --------- | ------- | ---------------------------------------------------------------------- |
|
|
176
|
+
| `acUseTextAttr` | `boolean` | `false` | When set, the text-attribute will be used instead of node textContent |
|
|
177
|
+
|
|
178
|
+
#### PySceneDetect toString() options
|
|
179
|
+
|
|
180
|
+
| option | type | default | description |
|
|
181
|
+
| ------------------ | -------- | -------- | ---------------------------------------- |
|
|
182
|
+
| `psdFramerate` | `number` | `23.976` | Framerate of the video file |
|
|
183
|
+
| `psdOmitTimecodes` | `boolen` | `false` | When set, the first line will be omitted |
|
|
184
|
+
|
|
185
|
+
#### Scenecut toString() options
|
|
186
|
+
|
|
187
|
+
| option | type | default | description |
|
|
188
|
+
| ----------- | -------- | ------- | --------------------------- |
|
|
189
|
+
| `frameRate` | `number` | `30` | Framerate of the video file |
|
|
190
|
+
| `ptsScale` | `number` | `1` | PTS scale (See below) |
|
|
191
|
+
| `score` | `number` | `0.5` | Score threshold |
|
|
192
|
+
|
|
193
|
+
When asked about the `ptsScale`-value, ChatGPT said:
|
|
194
|
+
> The number "1001" in the context of video processing and multimedia, especially in relation to frame rates and timecodes, is often associated with the NTSC color system used in North America and Japan.
|
|
195
|
+
> In this system, the frame rate is often described as "29.97 frames per second", but it's technically 30000/1001 frames per second, which is approximately 29.97 but not exactly. This is known as a "drop frame" rate, and the "1001" comes from this fractional frame rate.
|
|
196
|
+
|
|
197
|
+
When you use `1` the output `pts` will be the same as the `frame` number. When you use `1001` the output `pts` will be the same as the `frame` number multiplied by `1001`.
|