Skip to content

Commit 192c304

Browse files
committed
Update api.md
1 parent 308e9d1 commit 192c304

File tree

1 file changed

+13
-32
lines changed

1 file changed

+13
-32
lines changed

docs/api.md

Lines changed: 13 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ API
66
- [Worker.write](#worker-write)
77
- [Worker.writeText](#worker-writeText)
88
- [Worker.read](#worker-read)
9-
- [Worker.mkdir](#worker-mkdir)
109
- [Worker.remove](#worker-remove)
1110
- [Worker.transcode](#worker-transcode)
1211
- [Worker.trim](#worker-trim)
@@ -56,15 +55,14 @@ Worker.load() loads ffmpeg-core.js script (download from remote if not presented
5655
```
5756

5857
<a name="worker-write"></a>
59-
### Worker.write(path, data, jobId): Promise
58+
### Worker.write(path, data): Promise
6059

6160
Worker.write() writes data to specific path in Emscripten file system, it is an essential step before doing any other tasks.
6261

6362
**Arguments:**
6463

6564
- `path` path to write data to file system
6665
- `data` data to write, can be Uint8Array, URL or base64 format
67-
- `jobId` check Worker.load()
6866

6967
**Examples:**
7068

@@ -75,15 +73,14 @@ Worker.write() writes data to specific path in Emscripten file system, it is an
7573
```
7674

7775
<a name="worker-writeText"></a>
78-
### Worker.writeText(path, text, jobId): Promise
76+
### Worker.writeText(path, text): Promise
7977

8078
Worker.write() writes text data to specific path in Emscripten file system.
8179

8280
**Arguments:**
8381

8482
- `path` path to write data to file system
8583
- `text` string to write to file
86-
- `jobId` check Worker.load()
8784

8885
**Examples:**
8986

@@ -94,14 +91,14 @@ Worker.write() writes text data to specific path in Emscripten file system.
9491
```
9592

9693
<a name="worker-read"></a>
97-
### Worker.read(path, jobId): Promise
94+
### Worker.read(path, del): Promise
9895

9996
Worker.read() reads data from file system, often used to get output data after specific task.
10097

10198
**Arguments:**
10299

103100
- `path` path to read data from file system
104-
- `jobId` check Worker.load()
101+
- `del` whether to delete file in IDBFS or NODEFS, default: true
105102

106103
**Examples:**
107104

@@ -111,33 +108,14 @@ Worker.read() reads data from file system, often used to get output data after s
111108
})();
112109
```
113110

114-
<a name="worker-mkdir"></a>
115-
### Worker.mkdir(path, jobId): Promise
116-
117-
Worker.mkdir() creates a directory in file system, useful when you need to group files in a directory.
118-
119-
**Arguments:**
120-
121-
- `path` path to create directory
122-
- `jobId` check Worker.load()
123-
124-
**Examples:**
125-
126-
```javascript
127-
(async () => {
128-
await worker.mkdir('/video-clips');
129-
})();
130-
```
131-
132111
<a name="worker-remove"></a>
133-
### Worker.remove(path, jobId): Promise
112+
### Worker.remove(path): Promise
134113

135114
Worker.remove() removes files in file system, it will be better to delete unused files if you need to run ffmpeg.js multiple times.
136115

137116
**Arguments:**
138117

139118
- `path` path for file to delete
140-
- `jobId` check Worker.load()
141119

142120
**Examples:**
143121

@@ -148,7 +126,7 @@ Worker.remove() removes files in file system, it will be better to delete unused
148126
```
149127

150128
<a name="worker-transcode"></a>
151-
### Worker.transcode(inputPath, outputPath, options, jobId): Promise
129+
### Worker.transcode(inputPath, outputPath, options, del, jobId): Promise
152130

153131
Worker.transcode() transcode a video file to another format.
154132

@@ -157,6 +135,7 @@ Worker.transcode() transcode a video file to another format.
157135
- `inputPath` input file path, the input file should be written through Worker.write()
158136
- `outputPath` output file path, can be read with Worker.read() later
159137
- `options` a string to add extra arguments to ffmpeg
138+
- `del` a boolean to determine whether to delete input file after the task is done, default: true
160139
- `jobId` check Worker.load()
161140

162141
**Examples:**
@@ -168,7 +147,7 @@ Worker.transcode() transcode a video file to another format.
168147
```
169148

170149
<a name="worker-trim"></a>
171-
### Worker.trim(inputPath, outputPath, from, to, options, jobId): Promise
150+
### Worker.trim(inputPath, outputPath, from, to, options, del, jobId): Promise
172151

173152
Worker.trim() trims video to specific interval.
174153

@@ -179,6 +158,7 @@ Worker.trim() trims video to specific interval.
179158
- `from` start time, can be in time stamp (00:00:12.000) or seconds (12)
180159
- `to` end time, rule same as above
181160
- `options` a string to add extra arguments to ffmpeg
161+
- `del` a boolean to determine whether to delete input file after the task is done, default: true
182162
- `jobId` check Worker.load()
183163

184164
**Examples:**
@@ -190,19 +170,20 @@ Worker.trim() trims video to specific interval.
190170
```
191171

192172
<a name="worker-run"></a>
193-
### Worker.run(args, jobId): Promise
173+
### Worker.run(args, options, jobId): Promise
194174

195175
Worker.run() is similar to FFmpeg cli tool, aims to provide maximum flexiblity for users.
196176

197177
**Arguments:**
198178

199-
- `args` a string to represent arguments
179+
- `args` a string to represent arguments, note: inputPath must start with `/data/` as worker.write write to this path by default.
180+
- `options` a object to define the value for inputPath, outputPath and del.
200181
- `jobId` check Worker.load()
201182

202183
**Examples:**
203184

204185
```javascript
205186
(async () => {
206-
await worker.run('-i flame.avi -s 1920x1080 output.mp4');
187+
await worker.run('-i /data/flame.avi -s 1920x1080 output.mp4', { inputPath: 'flame.avi', outputPath: 'output.mp4' });
207188
})();
208189
```

0 commit comments

Comments
 (0)