Polyfill for WebCodecs, powered by ffmpeg.wasm
Go to file
2020-11-03 17:42:38 +08:00
.github Update FUNDING.yml 2020-11-03 15:54:06 +08:00
docs Update docs 2020-11-03 15:39:56 +08:00
examples Update examples 2020-11-03 15:39:01 +08:00
scripts Update test-helper 2020-11-03 15:38:39 +08:00
src Remove v in version and add locateFile func to fix worker script issue 2020-11-03 17:41:42 +08:00
tests Refactor tests 2020-11-03 15:37:45 +08:00
_config.yml Set theme jekyll-theme-cayman 2019-10-25 19:22:25 +08:00
.eslintrc Update .eslintrc to enable console 2020-11-03 15:39:45 +08:00
.gitattributes Init commit 2019-10-20 22:37:37 +08:00
.gitignore Adding two tests for command parser. 2020-04-14 03:30:17 +01:00
.gitpod.Dockerfile Update .gitpod.Dockerfile 2019-11-07 07:15:19 +08:00
.gitpod.yml Add test 2019-11-06 13:07:12 +00:00
.npmignore Update .npmignore 2019-11-06 13:10:00 +00:00
CODE_OF_CONDUCT.md Create CODE_OF_CONDUCT.md 2019-10-23 14:21:41 +08:00
CONTRIBUTING.md Create CONTRIBUTING.md 2019-10-23 14:22:11 +08:00
LICENSE Create LICENSE 2019-10-23 14:20:17 +08:00
package-lock.json Upgrade @ffmpeg/core and fix test script 2020-11-03 17:42:38 +08:00
package.json Upgrade @ffmpeg/core and fix test script 2020-11-03 17:42:38 +08:00
README.md Update README.md 2020-11-03 17:42:12 +08:00

ffmpeg.wasm

ffmpeg.wasm

Node Version Actions Status CodeQL npm (tag) Maintenance License: MIT Code Style Downloads Total Downloads Month

ffmpeg.wasm is a pure Webassembly / Javascript port of FFmpeg. It enables video & audio record, convert and stream right inside browsers.

Transcode

transcode-demo

codepen

Source Code

Browsers support

Chrome
Chrome
last 2 versions

Examples:

Name Demo Source Code
Webcam codepen Link

Supported External Libraries

Check HERE

Installation

$ npm install @ffmpeg/ffmpeg @ffmpeg/core

As we are using the latest experimental features, you need to add few flags to run in Node.js

$ node --experimental-wasm-threads --experimental-wasm-bulk-memory transcode.js

Or, using a script tag in the browser (only works in Chrome):

<script src="https://unpkg.com/@ffmpeg/ffmpeg@0.9.2/dist/ffmpeg.min.js"></script>
<script>
  const { createFFmpeg } = FFmpeg;
  ...
</script>

Usage

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

const fs = require('fs');
const { createFFmpeg, fetchFile } = require('@ffmpeg/ffmpeg');

const ffmpeg = createFFmpeg({ log: true });

(async () => {
  await ffmpeg.load();
  ffmpeg.FS('writeFile', 'test.avi', await fetchFile('./test.avi'));
  await ffmpeg.run('-i', 'test.avi', 'test.mp4');
  fs.writeFileSync('./test.mp4', ffmpeg.FS('readFile', 'test.mp4'));
  process.exit(0);
})();

Multi-threading

Multi-threading need to be configured per external libraries, only following libraries supports it now:

x264

Run it multi-threading mode by default, no need to pass any arguments.

libvpx / webm

Need to pass -row-mt 1, but can only use one thread to help, can speed up around 30%

Documentation