Polyfill for WebCodecs, powered by ffmpeg.wasm
Go to file
2020-05-05 18:16:52 +08:00
.github Refactor to remove IDBFS & NODEFS, use Transferable to handle large files 2020-01-13 22:07:47 +08:00
docs Fix docs 2020-05-05 17:51:29 +08:00
examples Add multiple-output example 2020-05-05 17:51:57 +08:00
scripts Major refactor to adapt new ffmpeg-core.js 2020-04-28 19:35:57 +08:00
src Fix conflicts 2020-05-05 18:16:52 +08:00
tests Fix conflicts 2020-05-05 18:16:52 +08:00
_config.yml Set theme jekyll-theme-cayman 2019-10-25 19:22:25 +08:00
.eslintrc Add image2video example 2019-11-21 21:31:25 +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 Release v0.8.2 2020-05-05 17:54:30 +08:00
package.json Release v0.8.2 2020-05-05 17:54:30 +08:00
README.md Release v0.8.2 2020-05-05 17:54:30 +08:00

Please visit Kagami/ffmpeg.js if you are looking for ffmpeg.js

ffmpeg.wasm

ffmpeg.wasm

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

Use FFmpeg directly in your browser without any backend services!!

Transcode

transcode-demo

codepen

Source Code

Browsers support

Chrome
Chrome
last 2 versions

Examples:

Name Demo Source Code
Webcam codepen Link

Supported Formats

  • mp4 (x264)
  • webm (vp8/vp9) (^0.8.0)
  • mp3 (^0.8.0)

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

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

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

(async () => {
  await ffmpeg.load();
  await ffmpeg.write('test.avi', './test.avi');
  await ffmpeg.transcode('test.avi', 'test.mp4');
  fs.writeFileSync('./test.mp4', ffmpeg.read('test.mp4'));
  process.exit(0);
})();

Installation

$ npm install @ffmpeg/ffmpeg

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.8.2/dist/ffmpeg.min.js"></script>
<script>
  const { createFFmpeg } = FFmpeg;
  ...
</script>

Multi-thread

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.

// in transcode()
await ffmpeg.transcode('flame.avi', 'flame.mp4', '-threads 2');

// in run()
await ffmpeg.run('-i flame.avi -threads 2 flame.mp4');

Examples

Documentation

Tutorials

Learn how to build ffmpeg.wasm from stories: