From 89be7a8b64a8f634b5b775f4aec817b4e4de13d7 Mon Sep 17 00:00:00 2001 From: Jerome Wu Date: Tue, 3 Nov 2020 15:52:33 +0800 Subject: [PATCH] Update README.md --- README.md | 44 ++++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/README.md b/README.md index 5c58019..63ee26a 100644 --- a/README.md +++ b/README.md @@ -47,25 +47,6 @@ ffmpeg.wasm is a pure Webassembly / Javascript port of FFmpeg. It enables video Check [HERE](https://github.com/ffmpegwasm/ffmpeg.wasm-core#configuration) ---- - -ffmpeg.wasm provides simple to use APIs, to transcode a video you only need few lines of code: - -```javascript -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.transcode('test.avi', 'test.mp4'); - fs.writeFileSync('./test.mp4', ffmpeg.FS('readFile', 'test.mp4')); - process.exit(0); -})(); -``` - ## Installation ``` @@ -81,13 +62,32 @@ $ node --experimental-wasm-threads --experimental-wasm-bulk-memory transcode.js Or, using a script tag in the browser (only works in Chrome): ```html - + ``` +## Usage + +ffmpeg.wasm provides simple to use APIs, to transcode a video you only need few lines of code: + +```javascript +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: @@ -100,10 +100,6 @@ Run it multi-threading mode by default, no need to pass any arguments. Need to pass `-row-mt 1`, but can only use one thread to help, can speed up around 30% -## Examples - -- With React: https://github.com/ffmpegwasm/react-app - ## Documentation - [API](https://github.com/ffmpegwasm/ffmpeg.wasm/blob/master/docs/api.md)