Socket
Socket
Sign inDemoInstall

@ffmpeg.wasm/main

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ffmpeg.wasm/main - npm Package Compare versions

Comparing version 0.12.0 to 0.13.0

dist/index.d.mts

110

package.json
{
"name": "@ffmpeg.wasm/main",
"version": "0.12.0",
"description": "FFmpeg WebAssembly version",
"main": "src/index.js",
"types": "src/index.d.ts",
"directories": {
"example": "examples"
},
"scripts": {
"start": "node scripts/server.js",
"start:worker": "node scripts/worker-server.js",
"build": "rimraf dist && webpack --config scripts/webpack.config.prod.js",
"build:worker": "rimraf dist && webpack --config scripts/webpack.config.worker.prod.js",
"prepublishOnly": "npm run build",
"lint": "eslint src",
"wait": "rimraf dist && wait-on http://localhost:3000/dist/ffmpeg.dev.js",
"test": "npm-run-all -p -r start test:all",
"test:all": "npm-run-all wait test:browser:ffmpeg test:node:all",
"test:node": "node node_modules/mocha/bin/_mocha --exit --bail --require ./scripts/test-helper.js",
"test:node:all": "npm run test:node -- ./tests/*.test.js",
"test:browser": "mocha-headless-chrome -a allow-file-access-from-files -a incognito -a no-sandbox -a disable-setuid-sandbox -a disable-logging -t 300000",
"test:browser:ffmpeg": "npm run test:browser -- -f ./tests/ffmpeg.test.html"
},
"browser": {
"./src/node/index.js": "./src/browser/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/DreamOfIce/ffmpeg.wasm.git"
},
"version": "0.13.0",
"description": "WebAssembly version of FFmpeg",
"keywords": [

@@ -37,40 +10,57 @@ "ffmpeg",

],
"author": "Jerome Wu <jeromewus@gmail.com>",
"license": "MIT",
"homepage": "https://github.com/ffmpeg.wasm/ffmpeg.wasm#readme",
"bugs": {
"url": "https://github.com/DreamOfIce/ffmpeg.wasm/issues"
"url": "https://github.com/ffmpeg.wasm/ffmpeg.wasm/issues"
},
"engines": {
"node": ">=12.16.1"
"repository": {
"type": "git",
"url": "git+https://github.com/ffmpeg.wasm/ffmpeg.wasm.git"
},
"homepage": "https://github.com/DreamOfIce/ffmpeg.wasm#readme",
"dependencies": {
"is-url": "^1.2.4",
"node-fetch": "^2.6.9",
"regenerator-runtime": "^0.13.11"
},
"license": "MIT",
"author": "Jerome Wu <jeromewus@gmail.com>",
"main": "dist/index.js",
"module": "dist/index.mjs",
"types": "dist/index.d.ts",
"files": [
"dist"
],
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/preset-env": "^7.12.1",
"@ffmpeg.wasm/core-mt": "^0.12.0",
"@types/emscripten": "^1.39.4",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.1.0",
"chai": "^4.2.0",
"cors": "^2.8.5",
"eslint": "^8.37.0",
"eslint-config-airbnb-base": "^15.0.0",
"eslint-plugin-import": "^2.27.5",
"express": "^4.17.1",
"mocha": "^10.1.0",
"mocha-headless-chrome": "^2.0.3",
"npm-run-all2": "^6.0.4",
"wait-on": "^5.3.0",
"webpack": "^5.3.2",
"webpack-cli": "^4.1.0",
"webpack-dev-middleware": "^4.0.0"
"@commitlint/cli": "^17.6.7",
"@commitlint/config-conventional": "^17.6.7",
"@ffmpeg.wasm/core-mt": "^0.13.2",
"@ffmpeg.wasm/core-st": "^0.13.2",
"@release-it/conventional-changelog": "^7.0.0",
"@tsconfig/esm": "^1.0.4",
"@tsconfig/node-lts": "^18.12.3",
"@tsconfig/strictest": "^2.0.1",
"@types/emscripten": "^1.39.6",
"@types/node": "^20.4.4",
"@typescript-eslint/eslint-plugin": "^6.1.0",
"@typescript-eslint/parser": "^6.1.0",
"eslint": "^8.45.0",
"eslint-config-prettier": "^8.8.0",
"file-type": "^18.5.0",
"husky": "^8.0.3",
"nano-staged": "^0.8.0",
"prettier": "^3.0.0",
"prettier-plugin-packagejson": "^2.4.5",
"release-it": "^16.1.3",
"tsup": "^7.1.0",
"typescript": "^5.1.6",
"vitest": "^0.33.0"
},
"engines": {
"node": ">=14.0.0"
},
"publishConfig": {
"access": "public"
},
"scripts": {
"build": "tsup",
"lint": "pnpm run \"/^lint:.*/\"",
"lint:eslint": "eslint --ext .ts --fix ./src",
"lint:prettier": "prettier --write .",
"release": "release-it",
"test": "vitest"
}
}
}

@@ -1,22 +0,11 @@

<p align="center">
<a href="#">
<img alt="ffmpeg.wasm" width="128px" height="128px" src="https://github.com/DreamOfIce/ffmpeg.wasm/raw/master/docs/images/ffmpegwasm-icon.png">
</a>
</p>
# FFmpeg.wasm
# ffmpeg.wasm
[![npm (scoped)](https://img.shields.io/npm/v/%40ffmpeg.wasm/main)](https://www.npmjs.com/package/@ffmpeg.wasm/main)
[![NPM Downloads](https://img.shields.io/npm/dm/@ffmpeg.wasm/main.svg)](https://www.npmjs.com/package/@ffmpeg.wasm/main)
[![JSdelivr Downloads](https://data.jsdelivr.com/v1/package/npm/@ffmpeg.wasm/main/badge)](https://www.jsdelivr.com/package/npm/@ffmpeg.wasm/main)
[![LICENSE](https://img.shields.io/npm/l/%40ffmpeg.wasm%2Fmain)](./LICENSE)
[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg)](CODE_OF_CONDUCT.md)
[![stability-experimental](https://img.shields.io/badge/stability-experimental-orange.svg)](https://github.com/emersion/stability-badges#experimental)
[![Node Version](https://img.shields.io/node/v/@ffmpeg.wasm/main.svg)](https://img.shields.io/node/v/@ffmpeg.wasm/main.svg)
[![Actions Status](https://github.com/DreamOfIce/ffmpeg.wasm/workflows/CI/badge.svg)](https://github.com/DreamOfIce/ffmpeg.wasm/actions)
![CodeQL](https://github.com/DreamOfIce/ffmpeg.wasm/workflows/CodeQL/badge.svg)
![npm (tag)](https://img.shields.io/npm/v/@ffmpeg.wasm/main/latest)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg)](https://github.com/DreamOfIce/ffmpeg.wasm/graphs/commit-activity)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![Code Style](https://badgen.net/badge/code%20style/airbnb/ff5a5f?icon=airbnb)](https://github.com/airbnb/javascript)
[![Downloads Total](https://img.shields.io/npm/dt/@ffmpeg.wasm/main.svg)](https://www.npmjs.com/package/@ffmpeg.wasm/main)
[![Downloads Month](https://img.shields.io/npm/dm/@ffmpeg.wasm/main.svg)](https://www.npmjs.com/package/@ffmpeg.wasm/main)
## About this fork
## About ffmpeg.wasm
Thanks to [Jerome Wu](https://github.com/jeromewu) for creating the very cool package ffmpegwasm!

@@ -32,4 +21,3 @@ However, because this package hasn't been updated in a long time, a lot of features are on hold and it's not compatible with node18 and above (because the emsdk version is too old). So I decided to maintain a fork, fix the problems and continue development iterations.

- v0.12 is fully compatible with ffmpegwasm v0.11.x, but updates emsdk to the latest and fixes some bugs
- Since v0.13, I will start refactoring with a modern toolchain (Typescript, vite, etc), **which will bring some breaking changes**.
**Therefore, it is strongly recommended that you ensure that you use `~0.12.0` when installing to ensure compatibility!**
- Since v0.13, I will start refactoring with a modern toolchain (TypeScript, vite, etc), **which will bring some breaking changes**.

@@ -42,4 +30,3 @@ ### Migration from ffmpegwasm

- `@ffmpeg/core-st` => `@ffmpeg.wasm/core-st`
- `@ffmpeg/types` is expected to be bundled with `@ffmpeg.wasm/main` in v0.13
2. Update version to `~0.12.0`
2. Update version to `^0.12.0`

@@ -49,30 +36,20 @@ ### Todos

- [x] Update emsdk to latest
- [ ] Update deps
- [ ] Rewrite with TypeScript (expected in v0.13)
- [ ] ESM Support (expected in v0.13)
- [ ] Migrate to pnpm (expected in v0.13)
- [ ] Support for parallel tasks in multi-threaded mode
- [ ] Release with Github Action
- [ ] Bundle with `vite` and test with `vitest`
- [x] Release with Github Action
- [x] Migrate to pnpm
- [x] ESM Support
- [x] Test with `vitest`
- [x] Update deps
- [x] Rewrite with TypeScript
- [x] Support for parallel tasks in multi-threaded mode
- [ ] Document site
- [ ] Support build cache
- [ ] Migrate to monorepo
- [ ] Upgrade to FFmpeg@5
- [ ] SIMD and WASI version
- [ ] Upgrade to FFmpeg@6
- [ ] Use the faster `libsvtav1` instead of `libaom` (currently disabled because it is too slow)
## Original README
## Original readme
ffmpeg.wasm is a pure Webassembly / Javascript port of FFmpeg. It enables video & audio record, convert and stream right inside browsers.
ffmpeg.wasm is a pure Webassembly port of FFmpeg. It enables video & audio record, convert and stream right inside browsers.
**AVI to MP4 Demo**
<p align="center">
<a href="#">
<img alt="transcode-demo" src="https://github.com/DreamOfIce/ffmpeg.wasm/raw/master/docs/images/transcode.gif">
</a>
</p>
Try it: [https://ffmpegwasm.netlify.app](https://ffmpegwasm.netlify.app#demo)
Check next steps of ffmpeg.wasm [HERE](https://github.com/DreamOfIce/ffmpeg.wasm/discussions/415)
## Installation

@@ -86,8 +63,2 @@

> As we are using experimental features, you need to add flags to run in Node.js
```
$ node --experimental-wasm-threads transcode.js
```
**Browser**

@@ -97,43 +68,42 @@

> SharedArrayBuffer is only available to pages that are [cross-origin isolated](https://developer.chrome.com/blog/enabling-shared-array-buffer/#cross-origin-isolation). So you need to host [your own server](https://github.com/DreamOfIce/ffmpegwasm.github.io/blob/main/server/server.js) with `Cross-Origin-Embedder-Policy: require-corp` and `Cross-Origin-Opener-Policy: same-origin` headers to use ffmpeg.wasm.
> Only browsers with `SharedArrayBuffer` support can use multi-thread core(`@ffmpeg.wasm/core-mt`), you can check [HERE](https://caniuse.com/sharedarraybuffer) for the complete list.
> [SharedArrayBuffer](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer) is only available to pages that are [cross-origin isolated](https://developer.chrome.com/blog/enabling-shared-array-buffer/#cross-origin-isolation). You need to send headers `Cross-Origin-Embedder-Policy: require-corp` and `Cross-Origin-Opener-Policy: same-origin` for your site, and make sure your static resource server(or public CDN) contains the header `Cross-Origin-Resource-Policy: cross-origin`(e.g. [JSdelivr](https://jsdelivr.com), not [Unpkg](https://unpkg.com))
```html
<script src="static/js/ffmpeg.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/@ffmpeg.wasm/main/dist/index.global.js"></script>
<script>
const { createFFmpeg } = FFmpeg;
...
const ffmpeg = FFmpeg.create({
/* ... */
});
</script>
```
> Only browsers with SharedArrayBuffer support can use ffmpeg.wasm, you can check [HERE](https://caniuse.com/sharedarraybuffer) for the complete list.
## Usage
ffmpeg.wasm provides simple to use APIs, to transcode a video you only need few lines of code:
`ffmpeg.wasm` provides simple to use APIs, to transcode a video you only need few lines of code:
```javascript
import { writeFile } from "fs/promises";
import { createFFmpeg, fetchFile } from "@ffmpeg.wasm/main";
```ts
import { readFile, writeFile } from "fs/promises";
import { FFmpeg } from "@ffmpeg.wasm/main";
const ffmpeg = createFFmpeg({ log: true });
const ffmpeg = await FFmpeg.create({ core: "@ffmpeg.wasm/core-mt" });
(async () => {
await ffmpeg.load();
ffmpeg.FS("writeFile", "test.avi", await fetchFile("./test.avi"));
await ffmpeg.run("-i", "test.avi", "test.mp4");
await fs.promises.writeFile("./test.mp4", ffmpeg.FS("readFile", "test.mp4"));
process.exit(0);
})();
ffmpeg.fs.writeFile("test.avi", await readFile("./test.avi"));
await ffmpeg.run("-i", "test.avi", "test.mp4");
await writeFile("./test.mp4", ffmpeg.fs.readFile("test.mp4"));
process.exit(0);
```
### Use other version of ffmpeg.wasm-core / @ffmpeg.wasm/core-mt
### Use other version of ffmpeg.wasm core
For each version of ffmpeg.wasm, there is a default version of @ffmpeg.wasm/core-mt (you can find it in **devDependencies** section of [package.json](https://github.com/DreamOfIce/ffmpeg.wasm/blob/master/package.json)), but sometimes you may need to use newer version of @ffmpeg.wasm/core-mt to use the latest/experimental features.
For each version of ffmpeg.wasm, there is a default version of `@ffmpeg.wasm/core-mt` (you can find it in `devDependencies` section of [package.json](./package.json)), but sometimes you may need to use newer version of `@ffmpeg.wasm/core-mt` to use the latest/experimental features.
**Warning:** before reaching v1.0.0, there may be incompatibilities between each minor version of the core, see the [migration guide](./docs/migrate/README.md) for more details!
**Node**
#### Node
Just install the specific version you need:
```bash
$ npm install @ffmpeg.wasm/core-mt@latest
```sh
$ npm install @ffmpeg.wasm/core-mt@$version
```

@@ -143,32 +113,21 @@

```javascript
const ffmpeg = createFFmpeg({
corePath: "../../../src/ffmpeg-core.js",
```ts
const ffmpeg = await FFmpeg.create({
core: "path/to/your/ffmpeg.wasm/core.js",
});
```
**Browser**
#### Browser
```javascript
const ffmpeg = createFFmpeg({
corePath: "static/js/ffmpeg-core.js",
```ts
const ffmpeg = await FFmpeg.create({
core: "https://cdn.jsdelivr.net/npm/@ffmpeg.wasm@$version/core-mt/dist/core.min.js",
});
```
Keep in mind that for compatibility with webworkers and nodejs this will default to a local path, so it will attempt to look for `'static/js/ffmpeg.core.js'` locally, often resulting in a local resource error. If you wish to use a core version hosted on your own domain, you might reference it relatively like this:
```javascript
const ffmpeg = createFFmpeg({
corePath: new URL("static/js/ffmpeg-core.js", document.location).href,
});
```
For the list available versions and their changelog, please check: https://github.com/DreamOfIce/ffmpeg.wasm-core/releases
### Use single thread version
```javascript
const ffmpeg = createFFmpeg({
mainName: "main",
corePath: "https://unpkg.com/@ffmpeg.wasm/core-st@0.12.0/dist/ffmpeg-core.js",
```ts
const ffmpeg = await FFmpeg.create({
core: "@ffmpeg.wasm/core-st",
});

@@ -191,4 +150,4 @@ ```

- [API](https://github.com/DreamOfIce/ffmpeg.wasm/blob/master/docs/api.md)
- [Supported External Libraries](https://github.com/DreamOfIce/ffmpeg.wasm-core#configuration)
- [API](./docs/api.md)
- [Supported External Libraries](https://github.com/ffmpeg.wasm/ffmpeg.wasm-core#configuration)

@@ -201,4 +160,4 @@ ## FAQ

- @ffmpeg.wasm/main (https://github.com/DreamOfIce/ffmpeg.wasm)
- @ffmpeg.wasm/core-mt (https://github.com/DreamOfIce/ffmpeg.wasm-core)
- @ffmpeg.wasm/main (https://github.com/ffmpeg.wasm/ffmpeg.wasm)
- @ffmpeg.wasm/core-mt (https://github.com/ffmpeg.wasm/ffmpeg.wasm-core)

@@ -209,41 +168,4 @@ @ffmpeg.wasm/core-mt contains WebAssembly code which is transpiled from original FFmpeg C code with minor modifications, but overall it still following the same licenses as FFmpeg and its external libraries (as each external libraries might have its own license).

### Can I use ffmpeg.wasm in Firefox?
Yes, but only for Firefox 79+ with proper header in both client and server, visit https://ffmpegwasm.netlify.app to try whether your Firefox works.
![](https://user-images.githubusercontent.com/5723124/98955802-4cb20c80-253a-11eb-8f16-ce0298720a2a.png)
For more details: https://github.com/DreamOfIce/ffmpeg.wasm/issues/106
### What is the maximum size of input file?
2 GB, which is a hard limit in WebAssembly. Might become 4 GB in the future.
### How can I build my own ffmpeg.wasm?
In fact, it is ffmpeg.wasm-core most people would like to build.
To build on your own, you can check build.sh inside https://github.com/DreamOfIce/ffmpeg.wasm-core repository.
Also you can check this series of posts to learn more fundamental concepts:
- https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-1-preparation/
- https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-2-compile-with-emscripten/
- https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-3-v0.1/
- https://jeromewu.github.io/build-ffmpeg-webassembly-version-part-4-v0.2/
### Why it doesn't work in my local environment?
When calling `ffmpeg.load()`, by default it looks for `http://localhost:3000/node_modules/@ffmpeg.wasm/core-mt/dist/` to download essential files (ffmpeg-core.js, ffmpeg-core.wasm, ffmpeg-core.worker.js). It is necessary to make sure you have those files served there.
If you have those files serving in other location, you can rewrite the default behavior when calling `createFFmpeg()`:
```javascript
const { createFFmpeg } = FFmpeg;
const ffmpeg = createFFmpeg({
corePath: "http://localhost:3000/public/ffmpeg-core.js",
// Use public address if you don't want to host your own.
// corePath: 'https://unpkg.com/@ffmpeg.wasm/core-mt@0.10.0/dist/ffmpeg-core.js'
log: true,
});
```
1 GB, which is a hard limit in WebAssembly. Might become 4 GB in the future.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc