6
6
- [ Worker.write] ( #worker-write )
7
7
- [ Worker.writeText] ( #worker-writeText )
8
8
- [ Worker.read] ( #worker-read )
9
- - [ Worker.mkdir] ( #worker-mkdir )
10
9
- [ Worker.remove] ( #worker-remove )
11
10
- [ Worker.transcode] ( #worker-transcode )
12
11
- [ Worker.trim] ( #worker-trim )
@@ -56,15 +55,14 @@ Worker.load() loads ffmpeg-core.js script (download from remote if not presented
56
55
```
57
56
58
57
<a name =" worker-write " ></a >
59
- ### Worker.write(path, data, jobId ): Promise
58
+ ### Worker.write(path, data): Promise
60
59
61
60
Worker.write() writes data to specific path in Emscripten file system, it is an essential step before doing any other tasks.
62
61
63
62
** Arguments:**
64
63
65
64
- ` path ` path to write data to file system
66
65
- ` data ` data to write, can be Uint8Array, URL or base64 format
67
- - ` jobId ` check Worker.load()
68
66
69
67
** Examples:**
70
68
@@ -75,15 +73,14 @@ Worker.write() writes data to specific path in Emscripten file system, it is an
75
73
```
76
74
77
75
<a name =" worker-writeText " ></a >
78
- ### Worker.writeText(path, text, jobId ): Promise
76
+ ### Worker.writeText(path, text): Promise
79
77
80
78
Worker.write() writes text data to specific path in Emscripten file system.
81
79
82
80
** Arguments:**
83
81
84
82
- ` path ` path to write data to file system
85
83
- ` text ` string to write to file
86
- - ` jobId ` check Worker.load()
87
84
88
85
** Examples:**
89
86
@@ -94,14 +91,14 @@ Worker.write() writes text data to specific path in Emscripten file system.
94
91
```
95
92
96
93
<a name =" worker-read " ></a >
97
- ### Worker.read(path, jobId ): Promise
94
+ ### Worker.read(path, del ): Promise
98
95
99
96
Worker.read() reads data from file system, often used to get output data after specific task.
100
97
101
98
** Arguments:**
102
99
103
100
- ` 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
105
102
106
103
** Examples:**
107
104
@@ -111,33 +108,14 @@ Worker.read() reads data from file system, often used to get output data after s
111
108
})();
112
109
```
113
110
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
-
132
111
<a name =" worker-remove " ></a >
133
- ### Worker.remove(path, jobId ): Promise
112
+ ### Worker.remove(path): Promise
134
113
135
114
Worker.remove() removes files in file system, it will be better to delete unused files if you need to run ffmpeg.js multiple times.
136
115
137
116
** Arguments:**
138
117
139
118
- ` path ` path for file to delete
140
- - ` jobId ` check Worker.load()
141
119
142
120
** Examples:**
143
121
@@ -148,7 +126,7 @@ Worker.remove() removes files in file system, it will be better to delete unused
148
126
```
149
127
150
128
<a name =" worker-transcode " ></a >
151
- ### Worker.transcode(inputPath, outputPath, options, jobId): Promise
129
+ ### Worker.transcode(inputPath, outputPath, options, del, jobId): Promise
152
130
153
131
Worker.transcode() transcode a video file to another format.
154
132
@@ -157,6 +135,7 @@ Worker.transcode() transcode a video file to another format.
157
135
- ` inputPath ` input file path, the input file should be written through Worker.write()
158
136
- ` outputPath ` output file path, can be read with Worker.read() later
159
137
- ` 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
160
139
- ` jobId ` check Worker.load()
161
140
162
141
** Examples:**
@@ -168,7 +147,7 @@ Worker.transcode() transcode a video file to another format.
168
147
```
169
148
170
149
<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
172
151
173
152
Worker.trim() trims video to specific interval.
174
153
@@ -179,6 +158,7 @@ Worker.trim() trims video to specific interval.
179
158
- ` from ` start time, can be in time stamp (00:00:12.000) or seconds (12)
180
159
- ` to ` end time, rule same as above
181
160
- ` 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
182
162
- ` jobId ` check Worker.load()
183
163
184
164
** Examples:**
@@ -190,19 +170,20 @@ Worker.trim() trims video to specific interval.
190
170
```
191
171
192
172
<a name =" worker-run " ></a >
193
- ### Worker.run(args, jobId): Promise
173
+ ### Worker.run(args, options, jobId): Promise
194
174
195
175
Worker.run() is similar to FFmpeg cli tool, aims to provide maximum flexiblity for users.
196
176
197
177
** Arguments:**
198
178
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.
200
181
- ` jobId ` check Worker.load()
201
182
202
183
** Examples:**
203
184
204
185
``` javascript
205
186
(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 ' } );
207
188
})();
208
189
```
0 commit comments