Skip to main content
@capgo/capacitor-ffmpeg Media Open source

FFmpeg Capacitor plugin

Video encoding and processing powered by FFmpeg for compression and conversion

Install

bun add @capgo/capacitor-ffmpeg bunx cap sync
npm, pnpm or yarn
  • npm install @capgo/capacitor-ffmpeg
  • pnpm add @capgo/capacitor-ffmpeg
  • yarn add @capgo/capacitor-ffmpeg

Guide

How to use FFmpeg in Capacitor

Using @capgo/capacitor-ffmpeg

Exposes the FFmpeg API to Capacitor.

Install

bun add @capgo/capacitor-ffmpeg
bunx cap sync

bunx cap sync copies the plugin's native code into your native projects. Run it again after every plugin upgrade.

Import

import { CapacitorFFmpeg } from '@capgo/capacitor-ffmpeg';

API at a glance

Method Description
getCapabilities Return the machine-readable capability matrix for the current platform.
reencodeVideo Queue a video re-encode job.
convertImage Convert a still image into another format.
convertAudio Convert audio into another container or codec.

Examples

getCapabilities()

Return the machine-readable capability matrix for the current platform.

import { CapacitorFFmpeg } from '@capgo/capacitor-ffmpeg';

const result = await CapacitorFFmpeg.getCapabilities();
console.log(result);

reencodeVideo()

Queue a video re-encode job.

import { CapacitorFFmpeg } from '@capgo/capacitor-ffmpeg';

const result = await CapacitorFFmpeg.reencodeVideo({
  inputPath: 'path/to/file',
  outputPath: 'path/to/file',
  width: 1080,
  height: 1920,
});
console.log(result);

convertImage()

Convert a still image into another format.

import { CapacitorFFmpeg } from '@capgo/capacitor-ffmpeg';

const result = await CapacitorFFmpeg.convertImage({
  inputPath: 'path/to/file',
  outputPath: 'path/to/file',
  format: 'webp',
});
console.log(result);

convertAudio()

Convert audio into another container or codec.

import { CapacitorFFmpeg } from '@capgo/capacitor-ffmpeg';

const result = await CapacitorFFmpeg.convertAudio({
  inputPath: 'path/to/file',
  outputPath: 'path/to/file',
  format: 'm4a',
});
console.log(result);

Listen to events

addListener returns a handle. Call handle.remove() when the screen unmounts.

Full reference

Keep going from Using @capgo/capacitor-ffmpeg

If you are using Using @capgo/capacitor-ffmpeg to plan dashboard and API operations, connect it with @capgo/capacitor-ffmpeg for the implementation detail in @capgo/capacitor-ffmpeg, Getting Started for the implementation detail in Getting Started, API Overview for the implementation detail in API Overview, Introduction for the implementation detail in Introduction, and API Keys for the implementation detail in API Keys.

FAQ

FFmpeg plugin FAQ

How do I install the FFmpeg plugin in a Capacitor app?

Run "bun add @capgo/capacitor-ffmpeg" (or "npm install @capgo/capacitor-ffmpeg"), then run "bunx cap sync" so the iOS and Android projects pick up the native code. Import it from "@capgo/capacitor-ffmpeg" in your app code.

Does @capgo/capacitor-ffmpeg work with React, Vue and Angular?

Yes. FFmpeg is a Capacitor package, so it works with any web framework that runs inside Capacitor, including Ionic, React, Vue, Angular, Svelte and plain JavaScript.

Which Capacitor version does @capgo/capacitor-ffmpeg support?

Capgo plugins follow Capacitor's major version: use the plugin major version that matches your Capacitor major version (for example plugin v8 with Capacitor 8). The compatibility table in the GitHub README lists the maintained versions.

Is @capgo/capacitor-ffmpeg free and open source?

Yes. The source code is public on GitHub at https://github.com/Cap-go/capacitor-ffmpeg/ and the package is free to install from npm. Bug reports and pull requests are welcome.

Can I update code that uses FFmpeg without an App Store review?

Installing or upgrading the plugin changes native code, so it needs a new store build. After that, JavaScript, HTML and CSS changes that call the plugin can ship instantly with Capgo live updates.

Ship FFmpeg changes without waiting for app review

Once the plugin is in your store build, Capgo live updates push your JavaScript, HTML and CSS changes to users in minutes.

Start with Capgo