Skip to content

Commit f3b38bc

Browse files
committed
Refactor to remove IDBFS & NODEFS, use Transferable to handle large files
1 parent d386025 commit f3b38bc

File tree

20 files changed

+156
-275
lines changed

20 files changed

+156
-275
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
runs-on: ${{ matrix.os }}
1515
strategy:
1616
matrix:
17-
node_version: ['10'] #['8', '10', '12']
17+
node_version: ['12'] #['8', '10', '12']
1818
os: [ubuntu-latest] #[ubuntu-latest, windows-latest, macOS-latest]
1919

2020
steps:
@@ -28,3 +28,4 @@ jobs:
2828
run: |
2929
npm install
3030
npm run lint
31+
npm test

docs/api.md

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,15 @@ Worker.load() loads ffmpeg-core.js script (download from remote if not presented
5858

5959
<a name="worker-write"></a>
6060

61-
### Worker.write(path, data): Promise
61+
### Worker.write(path, data, jobId): Promise
6262

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

6565
**Arguments:**
6666

6767
- `path` path to write data to file system
6868
- `data` data to write, can be Uint8Array, URL or base64 format
69+
- `jobId` @see Worker.load()
6970

7071
**Examples:**
7172

@@ -80,14 +81,15 @@ Worker.write() writes data to specific path in Emscripten file system, it is an
8081

8182
<a name="worker-writeText"></a>
8283

83-
### Worker.writeText(path, text): Promise
84+
### Worker.writeText(path, text, jobId): Promise
8485

8586
Worker.write() writes text data to specific path in Emscripten file system.
8687

8788
**Arguments:**
8889

8990
- `path` path to write data to file system
9091
- `text` string to write to file
92+
- `jobId` @see Worker.load()
9193

9294
**Examples:**
9395

@@ -99,14 +101,14 @@ Worker.write() writes text data to specific path in Emscripten file system.
99101

100102
<a name="worker-read"></a>
101103

102-
### Worker.read(path, del): Promise
104+
### Worker.read(path, jobId): Promise
103105

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

106108
**Arguments:**
107109

108110
- `path` path to read data from file system
109-
- `del` whether to delete file in IDBFS or NODEFS, default: true
111+
- `jobId` @see Worker.load()
110112

111113
**Examples:**
112114

@@ -118,13 +120,14 @@ Worker.read() reads data from file system, often used to get output data after s
118120

119121
<a name="worker-remove"></a>
120122

121-
### Worker.remove(path): Promise
123+
### Worker.remove(path, jobId): Promise
122124

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

125127
**Arguments:**
126128

127129
- `path` path for file to delete
130+
- `jobId` @see Worker.load()
128131

129132
**Examples:**
130133

@@ -136,7 +139,7 @@ Worker.remove() removes files in file system, it will be better to delete unused
136139

137140
<a name="worker-transcode"></a>
138141

139-
### Worker.transcode(input, output, options, del, jobId): Promise
142+
### Worker.transcode(input, output, options, jobId): Promise
140143

141144
Worker.transcode() transcode a video file to another format.
142145

@@ -145,8 +148,7 @@ Worker.transcode() transcode a video file to another format.
145148
- `input` input file path, the input file should be written through Worker.write()
146149
- `output` output file path, can be read with Worker.read() later
147150
- `options` a string to add extra arguments to ffmpeg
148-
- `del` a boolean to determine whether to delete input file after the task is done, default: true
149-
- `jobId` check Worker.load()
151+
- `jobId` @see Worker.load()
150152

151153
**Examples:**
152154

@@ -158,7 +160,7 @@ Worker.transcode() transcode a video file to another format.
158160

159161
<a name="worker-trim"></a>
160162

161-
### Worker.trim(input, output, from, to, options, del, jobId): Promise
163+
### Worker.trim(input, output, from, to, options, jobId): Promise
162164

163165
Worker.trim() trims video to specific interval.
164166

@@ -169,8 +171,7 @@ Worker.trim() trims video to specific interval.
169171
- `from` start time, can be in time stamp (00:00:12.000) or seconds (12)
170172
- `to` end time, rule same as above
171173
- `options` a string to add extra arguments to ffmpeg
172-
- `del` a boolean to determine whether to delete input file after the task is done, default: true
173-
- `jobId` check Worker.load()
174+
- `jobId` @see Worker.load()
174175

175176
**Examples:**
176177

@@ -182,7 +183,7 @@ Worker.trim() trims video to specific interval.
182183

183184
<a name="worker-concatDemuxer"></a>
184185

185-
### Worker.concatDemuxer(input, output, options, del, jobId): Promise
186+
### Worker.concatDemuxer(input, output, options, jobId): Promise
186187

187188
Worker.concatDemuxer() concatenates multiple videos using concatDemuxer. This method won't encode the videos again. But it has its limitations. See [Concat demuxer Wiki](https://trac.ffmpeg.org/wiki/Concatenate)
188189

@@ -191,7 +192,6 @@ Worker.concatDemuxer() concatenates multiple videos using concatDemuxer. This me
191192
- `input` input file paths as an Array, the input files should be written through Worker.write()
192193
- `output` output file path, can be read with Worker.read() later
193194
- `options` a string to add extra arguments to ffmpeg
194-
- `del` a boolean to determine whether to delete input file after the task is done, default: true
195195
- `jobId` check Worker.load()
196196

197197
**Examples:**
@@ -204,26 +204,19 @@ Worker.concatDemuxer() concatenates multiple videos using concatDemuxer. This me
204204

205205
<a name="worker-run"></a>
206206

207-
### Worker.run(args, options, jobId): Promise
207+
### Worker.run(args, jobId): Promise
208208

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

211211
**Arguments:**
212212

213213
- `args` a string to represent arguments, note: inputPath must start with `/data/` as worker.write write to this path by default.
214-
- `options` a object to define the value for input, output and del.
215-
- `input` a string or an array of strings to indicate input files, ffmpeg.js deletes these files for you.
216-
- `output` a string or an array of strings to indicate output files, ffmpeg.js moves these files to `/data`, deletes them from MEMFS and you can read them with Worker.read()
217-
- `del` a boolean to determine whether to delete input file after the task is done, default: true
218214
- `jobId` check Worker.load()
219215

220216
**Examples:**
221217

222218
```javascript
223219
(async () => {
224-
await worker.run("-i /data/flame.avi -s 1920x1080 output.mp4", {
225-
input: "flame.avi",
226-
output: "output.mp4"
227-
});
220+
await worker.run("-i /data/flame.avi -s 1920x1080 output.mp4");
228221
})();
229222
```

package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"lint": "eslint src",
1414
"wait": "rimraf dist && wait-on http://localhost:3000/dist/ffmpeg.dev.js",
1515
"test": "npm-run-all -p -r start test:all",
16-
"test:all": "npm-run-all wait test:node:all",
16+
"test:all": "npm-run-all wait test:browser:ffmpeg test:node:all",
1717
"test:node": "nyc mocha --exit --bail --require ./scripts/test-helper.js",
1818
"test:node:all": "npm run test:node -- ./tests/*.test.js",
1919
"test:browser": "mocha-headless-chrome -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000",
@@ -38,7 +38,7 @@
3838
},
3939
"homepage": "https://github.com/ffmpegjs/ffmpeg.js#readme",
4040
"dependencies": {
41-
"@ffmpeg/core": "^0.5.0",
41+
"@ffmpeg/core": "^0.4.0",
4242
"idb": "^4.0.5",
4343
"is-electron": "^2.2.0",
4444
"is-url": "^1.2.4",

0 commit comments

Comments
 (0)