|
4 | 4 | - [createWorker()](#create-worker) |
5 | 5 | - [Worker.load](#worker-load) |
6 | 6 | - [Worker.write](#worker-write) |
| 7 | + - [Worker.writeText](#worker-writeText) |
7 | 8 | - [Worker.read](#worker-read) |
8 | 9 | - [Worker.mkdir](#worker-mkdir) |
9 | 10 | - [Worker.remove](#worker-remove) |
10 | 11 | - [Worker.transcode](#worker-transcode) |
| 12 | + - [Worker.trim](#worker-trim) |
11 | 13 | - [Worker.run](#worker-run) |
12 | 14 |
|
13 | 15 | --- |
@@ -72,6 +74,25 @@ Worker.write() writes data to specific path in Emscripten file system, it is an |
72 | 74 | })(); |
73 | 75 | ``` |
74 | 76 |
|
| 77 | +<a name="worker-writeText"></a> |
| 78 | +### Worker.writeText(path, text, jobId): Promise |
| 79 | + |
| 80 | +Worker.write() writes text data to specific path in Emscripten file system. |
| 81 | + |
| 82 | +**Arguments:** |
| 83 | + |
| 84 | +- `path` path to write data to file system |
| 85 | +- `text` string to write to file |
| 86 | +- `jobId` check Worker.load() |
| 87 | + |
| 88 | +**Examples:** |
| 89 | + |
| 90 | +```javascript |
| 91 | +(async () => { |
| 92 | + await worker.write('sub.srt', '...'); |
| 93 | +})(); |
| 94 | +``` |
| 95 | + |
75 | 96 | <a name="worker-read"></a> |
76 | 97 | ### Worker.read(path, jobId): Promise |
77 | 98 |
|
@@ -146,6 +167,28 @@ Worker.transcode() transcode a video file to another format. |
146 | 167 | })(); |
147 | 168 | ``` |
148 | 169 |
|
| 170 | +<a name="worker-trim"></a> |
| 171 | +### Worker.trim(inputPath, outputPath, from, to, options, jobId): Promise |
| 172 | + |
| 173 | +Worker.trim() trims video to specific interval. |
| 174 | + |
| 175 | +**Arguments:** |
| 176 | + |
| 177 | +- `inputPath` input file path, the input file should be written through Worker.write() |
| 178 | +- `outputPath` output file path, can be read with Worker.read() later |
| 179 | +- `from` start time, can be in time stamp (00:00:12.000) or seconds (12) |
| 180 | +- `to` end time, rule same as above |
| 181 | +- `options` a string to add extra arguments to ffmpeg |
| 182 | +- `jobId` check Worker.load() |
| 183 | + |
| 184 | +**Examples:** |
| 185 | + |
| 186 | +```javascript |
| 187 | +(async () => { |
| 188 | + await worker.trim('flame.avi', 'output.mp4', 1, 2); |
| 189 | +})(); |
| 190 | +``` |
| 191 | + |
149 | 192 | <a name="worker-run"></a> |
150 | 193 | ### Worker.run(args, jobId): Promise |
151 | 194 |
|
|
0 commit comments