ffmpeg.js - 实现无需任何后端服务即可直接在浏览器中使用FFmpeg

ffmpeg.js - 实现无需任何后端服务即可直接在浏览器中使用FFmpeg

JavaScript 其它杂项

访问GitHub主页

共797Star

详细介绍

ffmpeg.js

ffmpeg.js

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

Examples:

Name Demo Source Code
Webcam codepen Link

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

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

const worker = createWorker();

(async () => {
  await worker.load();
  await worker.write('test.avi', './test.avi');
  await worker.transcode('test.avi', 'test.mp4');
  const { data } = await worker.read('test.mp4');
  fs.writeFileSync('./test.mp4', data);
  await worker.terminate();
})();

Installation

$ npm install @ffmpeg/ffmpeg

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

Or, using a script tag in the browser:

<script src="https://unpkg.com/@ffmpeg/ffmpeg@0.7.0/dist/ffmpeg.min.js">script