Skip to content

Commit 043bdf4

Browse files
committed
Update documents
1 parent ef54a7b commit 043bdf4

File tree

14 files changed

+202
-244
lines changed

14 files changed

+202
-244
lines changed

README.md

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -36,24 +36,28 @@ Use FFmpeg directly in your browser without any backend services!!
3636
| ---- | ------- | ----------- |
3737
| Webcam | <a href="https://codepen.io/jeromewu/pen/qBBKzyW" target="_blank"><img alt="codepen" width="128px" src="https://blog.codepen.io/wp-content/uploads/2012/06/[email protected]"></a> | [Link](https://github.com/ffmpegjs/ffmpeg.js/blob/master/examples/browser/webcam.html) |
3838

39+
## Supported Formats
40+
41+
- mp4 (x264)
42+
- webm (vp8/vp9) (^0.8.0)
43+
- mp3 (^0.8.0)
3944

4045
---
4146

4247
ffmpeg.js provides simple to use APIs, to transcode a video you only need few lines of code:
4348

4449
```javascript
4550
const fs = require('fs');
46-
const { createWorker } = require('@ffmpeg/ffmpeg');
51+
const { createFFmpeg } = require('@ffmpeg/ffmpeg');
4752

48-
const worker = createWorker();
53+
const ffmpeg = createFFmpeg({ log: true });
4954

5055
(async () => {
51-
await worker.load();
52-
await worker.write('test.avi', './test.avi');
53-
await worker.transcode('test.avi', 'test.mp4');
54-
const { data } = await worker.read('test.mp4');
55-
fs.writeFileSync('./test.mp4', data);
56-
await worker.terminate();
56+
await ffmpeg.load();
57+
await ffmpeg.write('test.avi', './test.avi');
58+
await ffmpeg.transcode('test.avi', 'test.mp4');
59+
fs.writeFileSync('./test.mp4', ffmpeg.read('test.mp4'));
60+
process.exit(0);
5761
})();
5862
```
5963

@@ -63,18 +67,34 @@ const worker = createWorker();
6367
$ npm install @ffmpeg/ffmpeg
6468
```
6569

66-
> As we use `worker_threads` which was introduced in Node.js v10.5.0, please remember to add `--experimental-worker` if you are using Node.js v10, and you don't have to add anything if you are using Node.js v12
70+
> As we are using the latest experimental features, you need to add few flags to run in Node.js
6771
68-
Or, using a script tag in the browser:
72+
```
73+
$ node --experimental-wasm-threads --experimental-wasm-bulk-memory transcode.js
74+
```
75+
76+
Or, using a script tag in the browser (only works in Chrome):
6977

7078
```html
71-
<script src="https://unpkg.com/@ffmpeg/ffmpeg@0.7.0/dist/ffmpeg.min.js"></script>
79+
<script src="https://unpkg.com/@ffmpeg/ffmpeg@0.8.0/dist/ffmpeg.min.js"></script>
7280
<script>
73-
const { createWorker } = FFmpeg;
81+
const { createFFmpeg } = FFmpeg;
7482
...
7583
</script>
7684
```
7785

86+
## Multi-thread
87+
88+
Starting from v0.8.0, multithreading is enabled and you can use this feature by passing `-threads <NUM>` (`NUM` < 8 ). For built-in functions like `transcode()`, you can pass it as 3rd argument.
89+
90+
```javascript
91+
// in transcode()
92+
await ffmpeg.transcode('flame.avi', 'flame.mp4', '-threads 2');
93+
94+
// in run()
95+
await ffmpeg.run('-i flame.avi -threads 2 flame.mp4');
96+
```
97+
7898
## Examples
7999

80100
- With React: https://github.com/ffmpegjs/react-app
@@ -93,3 +113,4 @@ Learn how to build ffmpeg.js from stories:
93113
- [Part.4 ffmpeg.js v0.2 — Web Worker and Libx264](https://medium.com/@jeromewus/build-ffmpeg-webassembly-version-ffmpeg-js-part-4-ffmpeg-js-v0-2-web-worker-and-libx264-d0596f1beb4e)
94114
- [Part.5 ffmpeg.js v0.3 — pre-js and live streaming](https://medium.com/@jeromewus/build-ffmpeg-webassembly-version-ffmpeg-js-part-5-ffmpeg-js-v0-3-pre-js-and-live-streaming-c1498939a74c)
95115
- [Part.6 a Deep Dive into File System](https://medium.com/@jeromewus/build-ffmpeg-webassembly-version-ffmpeg-js-part-6-a-deep-dive-into-file-system-56eba10067ca)
116+
- [Part.7 multithreading (WIP)]()

0 commit comments

Comments
 (0)