diff --git a/docs/api.md b/docs/api.md
index 1be2595..907eb0f 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -8,6 +8,7 @@
- [Worker.remove](#worker-remove)
- [Worker.transcode](#worker-transcode)
- [Worker.trim](#worker-trim)
+ - [Worker.concatDemuxer](#worker-concatDemuxer)
- [Worker.run](#worker-run)
---
@@ -135,14 +136,14 @@ Worker.remove() removes files in file system, it will be better to delete unused
-### Worker.transcode(inputPath, outputPath, options, del, jobId): Promise
+### Worker.transcode(input, output, options, del, jobId): Promise
Worker.transcode() transcode a video file to another format.
**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
+- `input` input file path, the input file should be written through Worker.write()
+- `output` output file path, can be read with Worker.read() later
- `options` a string to add extra arguments to ffmpeg
- `del` a boolean to determine whether to delete input file after the task is done, default: true
- `jobId` check Worker.load()
@@ -157,7 +158,7 @@ Worker.transcode() transcode a video file to another format.
-### Worker.trim(inputPath, outputPath, from, to, options, del, jobId): Promise
+### Worker.trim(input, output, from, to, options, del, jobId): Promise
Worker.trim() trims video to specific interval.
@@ -181,14 +182,14 @@ Worker.trim() trims video to specific interval.
-### Worker.concatDemuxer(inputPaths, outputPath, options, del, jobId): Promise
+### Worker.concatDemuxer(input, output, options, del, jobId): Promise
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)
**Arguments:**
-- `inputPaths` input file paths as an Array, the input files should be written through Worker.write()
-- `outputPath` output file path, can be read with Worker.read() later
+- `input` input file paths as an Array, the input files should be written through Worker.write()
+- `output` output file path, can be read with Worker.read() later
- `options` a string to add extra arguments to ffmpeg
- `del` a boolean to determine whether to delete input file after the task is done, default: true
- `jobId` check Worker.load()
@@ -197,7 +198,7 @@ Worker.concatDemuxer() concatenates multiple videos using concatDemuxer. This me
```javascript
(async () => {
- await worker.trim(["flame-1.avi", "flame-2.avi"], "output.mp4");
+ await worker.concatDemuxer(["flame-1.avi", "flame-2.avi"], "output.mp4");
})();
```
@@ -210,7 +211,10 @@ Worker.run() is similar to FFmpeg cli tool, aims to provide maximum flexiblity f
**Arguments:**
- `args` a string to represent arguments, note: inputPath must start with `/data/` as worker.write write to this path by default.
-- `options` a object to define the value for inputPath, outputPath and del.
+- `options` a object to define the value for input, output and del.
+ - `input` a string or an array of strings to indicate input files, ffmpeg.js deletes these files for you.
+ - `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()
+ - `del` a boolean to determine whether to delete input file after the task is done, default: true
- `jobId` check Worker.load()
**Examples:**
@@ -218,8 +222,8 @@ Worker.run() is similar to FFmpeg cli tool, aims to provide maximum flexiblity f
```javascript
(async () => {
await worker.run("-i /data/flame.avi -s 1920x1080 output.mp4", {
- inputPath: "flame.avi",
- outputPath: "output.mp4"
+ input: "flame.avi",
+ output: "output.mp4"
});
})();
```
diff --git a/examples/browser/image2video.html b/examples/browser/image2video.html
index 76bfb64..831a3dd 100644
--- a/examples/browser/image2video.html
+++ b/examples/browser/image2video.html
@@ -38,7 +38,7 @@
await worker.write(`tmp.${num}.png`, `../../tests/assets/triangle/tmp.${num}.png`);
}
message.innerHTML = 'Start transcoding';
- await worker.run('-framerate 30 -pattern_type glob -i /data/*.png -i /data/audio.ogg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4', { outputPath: 'out.mp4' });
+ await worker.run('-framerate 30 -pattern_type glob -i /data/*.png -i /data/audio.ogg -c:a copy -shortest -c:v libx264 -pix_fmt yuv420p out.mp4', { output: 'out.mp4' });
const { data } = await worker.read('out.mp4');
await worker.remove('audio.ogg');
for (let i = 0; i < 60; i += 1) {
diff --git a/examples/browser/run.html b/examples/browser/run.html
index 565d4a0..36c1abe 100644
--- a/examples/browser/run.html
+++ b/examples/browser/run.html
@@ -33,7 +33,7 @@
await worker.load();
message.innerHTML = 'Start transcoding';
await worker.write(name, files[0]);
- await worker.run(`-i /data/${name} output.mp4`, { inputPath: name, outputPath: 'output.mp4' });
+ await worker.run(`-i /data/${name} output.mp4`, { input: name, output: 'output.mp4' });
message.innerHTML = 'Complete transcoding';
const { data } = await worker.read('output.mp4');
diff --git a/examples/browser/transcode.html b/examples/browser/transcode.html
index bf36b59..cb14c37 100644
--- a/examples/browser/transcode.html
+++ b/examples/browser/transcode.html
@@ -23,6 +23,7 @@
const { createWorker } = FFmpeg;
const worker = createWorker({
corePath: '../../node_modules/@ffmpeg/core/ffmpeg-core.js',
+ logger: ({ message }) => console.log(message),
progress: p => console.log(p),
});
@@ -36,7 +37,6 @@
await worker.transcode(name, 'output.mp4');
message.innerHTML = 'Complete transcoding';
const { data } = await worker.read('output.mp4');
- console.log(data);
const video = document.getElementById('output-video');
video.src = URL.createObjectURL(new Blob([data.buffer], { type: 'video/mp4' }));
diff --git a/examples/browser/trim.html b/examples/browser/trim.html
index 1e7ade0..8d8250b 100644
--- a/examples/browser/trim.html
+++ b/examples/browser/trim.html
@@ -15,7 +15,7 @@
-
Upload a mp4 (x264) video and trim its first 2 seconds and play!
+
Upload a mp4 (x264) video and trim its first 10 seconds and play!