diff --git a/docs/api.md b/docs/api.md
index da2e1b5..64aa62c 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -4,10 +4,12 @@ API
- [createWorker()](#create-worker)
- [Worker.load](#worker-load)
- [Worker.write](#worker-write)
+ - [Worker.writeText](#worker-writeText)
- [Worker.read](#worker-read)
- [Worker.mkdir](#worker-mkdir)
- [Worker.remove](#worker-remove)
- [Worker.transcode](#worker-transcode)
+ - [Worker.trim](#worker-trim)
- [Worker.run](#worker-run)
---
@@ -72,6 +74,25 @@ Worker.write() writes data to specific path in Emscripten file system, it is an
})();
```
+
+### Worker.writeText(path, text, jobId): Promise
+
+Worker.write() writes text data to specific path in Emscripten file system.
+
+**Arguments:**
+
+- `path` path to write data to file system
+- `text` string to write to file
+- `jobId` check Worker.load()
+
+**Examples:**
+
+```javascript
+(async () => {
+ await worker.write('sub.srt', '...');
+})();
+```
+
### Worker.read(path, jobId): Promise
@@ -146,6 +167,28 @@ Worker.transcode() transcode a video file to another format.
})();
```
+
+### Worker.trim(inputPath, outputPath, from, to, options, jobId): Promise
+
+Worker.trim() trims video to specific interval.
+
+**Arguments:**
+
+- `inputPath` input file path, the input file should be written through Worker.write()
+- `outputPath` output file path, can be read with Worker.read() later
+- `from` start time, can be in time stamp (00:00:12.000) or seconds (12)
+- `to` end time, rule same as above
+- `options` a string to add extra arguments to ffmpeg
+- `jobId` check Worker.load()
+
+**Examples:**
+
+```javascript
+(async () => {
+ await worker.trim('flame.avi', 'output.mp4', 1, 2);
+})();
+```
+
### Worker.run(args, jobId): Promise
diff --git a/examples/browser/trim.html b/examples/browser/trim.html
new file mode 100644
index 0000000..1e7ade0
--- /dev/null
+++ b/examples/browser/trim.html
@@ -0,0 +1,47 @@
+
+
+
+
+
+
+
Upload a mp4 (x264) video and trim its first 2 seconds and play!