1
- # Please visit [ Kagami/ffmpeg.js] ( https://github.com/Kagami/ffmpeg.js/ ) if you are looking for ffmpeg.js
2
-
3
-
4
1
<p align =" center " >
5
2
<a href =" # " >
6
3
<img alt="ffmpeg.wasm" width="128px" height="128px" src="https://github.com/ffmpegwasm/ffmpeg.wasm/raw/master/docs/images/ffmpegwasm-icon.png">
18
15
[ ![ Downloads Total] ( https://img.shields.io/npm/dt/@ffmpeg/ffmpeg.svg )] ( https://www.npmjs.com/package/@ffmpeg/ffmpeg )
19
16
[ ![ Downloads Month] ( https://img.shields.io/npm/dm/@ffmpeg/ffmpeg.svg )] ( https://www.npmjs.com/package/@ffmpeg/ffmpeg )
20
17
21
- Use FFmpeg directly in your browser without any backend services!!
18
+ ffmpeg.wasm is a pure Webassembly / Javascript port of FFmpeg. It enables video & audio record, convert and stream right inside browsers.
22
19
23
20
** Transcode**
24
21
<p align =" center " >
@@ -45,35 +42,33 @@ Use FFmpeg directly in your browser without any backend services!!
45
42
| ---- | ------- | ----------- |
46
43
| 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/ffmpegwasm/ffmpeg.wasm/blob/master/examples/browser/webcam.html ) |
47
44
48
- ## Supported Formats
45
+ ## Supported External Libraries
49
46
50
- - mp4 (x264)
51
- - webm (vp8/vp9) (^0.8.0)
52
- - mp3 (^0.8.0)
47
+ Check [ HERE] ( https://github.com/ffmpegwasm/ffmpeg.wasm-core#configuration )
53
48
54
49
---
55
50
56
51
ffmpeg.wasm provides simple to use APIs, to transcode a video you only need few lines of code:
57
52
58
53
``` javascript
59
54
const fs = require (' fs' );
60
- const { createFFmpeg } = require (' @ffmpeg/ffmpeg' );
55
+ const { createFFmpeg , fetchFile } = require (' @ffmpeg/ffmpeg' );
61
56
62
57
const ffmpeg = createFFmpeg ({ log: true });
63
58
64
59
(async () => {
65
60
await ffmpeg .load ();
66
- await ffmpeg .write ( ' test.avi' , ' ./test.avi' );
61
+ ffmpeg .FS ( ' writeFile ' , ' test.avi' , await fetchFile ( ' ./test.avi' ) );
67
62
await ffmpeg .transcode (' test.avi' , ' test.mp4' );
68
- fs .writeFileSync (' ./test.mp4' , ffmpeg .read ( ' test.mp4' ));
63
+ fs .writeFileSync (' ./test.mp4' , ffmpeg .FS ( ' readFile ' , ' test.mp4' ));
69
64
process .exit (0 );
70
65
})();
71
66
```
72
67
73
68
## Installation
74
69
75
70
```
76
- $ npm install @ffmpeg/ffmpeg
71
+ $ npm install @ffmpeg/ffmpeg @ffmpeg/core
77
72
```
78
73
79
74
> As we are using the latest experimental features, you need to add few flags to run in Node.js
@@ -92,17 +87,17 @@ Or, using a script tag in the browser (only works in Chrome):
92
87
</script >
93
88
```
94
89
95
- ## Multi-thread
90
+ ## Multi-threading
96
91
97
- 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.
92
+ Multi-threading need to be configured per external libraries, only following libraries supports it now:
98
93
99
- ``` javascript
100
- // in transcode()
101
- await ffmpeg .transcode (' flame.avi' , ' flame.mp4' , ' -threads 2' );
94
+ ### x264
102
95
103
- // in run()
104
- await ffmpeg .run (' -i flame.avi -threads 2 flame.mp4' );
105
- ```
96
+ Run it multi-threading mode by default, no need to pass any arguments.
97
+
98
+ ### libvpx / webm
99
+
100
+ Need to pass ` -row-mt 1 ` , but can only use one thread to help, can speed up around 30%
106
101
107
102
## Examples
108
103
@@ -111,12 +106,3 @@ await ffmpeg.run('-i flame.avi -threads 2 flame.mp4');
111
106
## Documentation
112
107
113
108
- [ API] ( https://github.com/ffmpegwasm/ffmpeg.wasm/blob/master/docs/api.md )
114
-
115
- ## Tutorials
116
-
117
- Learn how to build ffmpeg.wasm from stories:
118
-
119
- - [ Part.1 Preparation] ( https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-1-preparation/ )
120
- - [ Part.2 Compile with Emscripten] ( https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-2-compile-with-emscripten/ )
121
- - [ Part.3 ffmpeg.wasm v0.1— Transcoding avi to mp4] ( https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-3-v0.1/ )
122
- - [ Part.4 ffmpeg.wasm v0.2 — Web Worker and Libx264] ( https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-4-v0.2/ )
0 commit comments