flutter_ffmpeg_wasm 0.1.1
flutter_ffmpeg_wasm: ^0.1.1 copied to clipboard
Bundled single-thread FFmpeg WebAssembly runtime for Flutter web.
flutter_ffmpeg_wasm #
FFmpeg WebAssembly for Flutter web, shipped with pinned precompiled binaries. The application does not compile FFmpeg, contact a CDN, or require Emscripten at build or runtime.
Bundled runtime #
@ffmpeg/ffmpeg0.11.6@ffmpeg/core0.11.0 with WebAssembly threads@ffmpeg/core-st0.11.1 as an automatic compatibility fallback- Runtime, JavaScript core loader, and WASM binary served as Flutter assets
- Dedicated Web Worker keeps synchronous encoding off Flutter's UI thread
The runtime files, including the single-thread worker placeholder expected by
the upstream loader, live in assets/ffmpeg. The upstream source snapshot under
src is excluded from package publication and is not part of the Flutter
build.
Usage #
import 'package:flutter_ffmpeg_wasm/flutter_ffmpeg_wasm.dart';
final ffmpeg = createFFmpeg(const CreateFFmpegParam(log: false));
await ffmpeg.load();
ffmpeg.writeFile('input.mp4', inputBytes);
await ffmpeg.run(['-i', 'input.mp4', 'output.webm']);
final outputBytes = ffmpeg.readFile('output.webm');
ffmpeg.exit();
Use setProgress and setLogger before run to observe an encoding job.
Commands containing paths with spaces should use run(List<String>) instead
of runCommand(String).
Files written before run are transferred to the worker's MEMFS. When the
command finishes, its last argument is treated as the output path and is made
available through readFile.
Hosting #
Serve .wasm files using application/wasm. The package selects the
multi-thread core when crossOriginIsolated is true. Configure the page with:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Embedder-Policy: require-corp
Cross-Origin-Resource-Policy: same-origin
Without those headers, or in an incompatible browser, the package selects the single-thread build automatically.