ffmpeg_kit_flutter_new_converter_gpl 1.0.0
ffmpeg_kit_flutter_new_converter_gpl: ^1.0.0 copied to clipboard
FFmpeg Kit Converter-GPL for Flutter. FFmpeg with x264, x265, LAME, Opus, Vorbis, VP8/VP9, WebP and dav1d. Supports Android, iOS, macOS, Windows and Linux.
FFmpegKit for Flutter: Converter GPL #
Run FFmpeg and FFprobe commands from Dart on Android, iOS, macOS, Windows and Linux.
This is a maintained fork of FFmpegKit, which is no longer developed upstream, updated for the Android V2 embedding and current Flutter releases. ffmpeg_kit_flutter_new_converter_gpl is the Converter GPL variant: the encoders that converting between common audio and video formats needs (x264, x265, LAME, Opus, libvorbis, libvpx and libwebp) and the dav1d AV1 decoder, without the rest of the full build. See Choosing a package for the alternatives.
Features #
- FFmpeg 8.1.3 and FFprobe, with per-session logs, statistics and completion callbacks.
- One Dart API for Android, iOS, macOS, Windows (x86_64) and Linux (x86_64).
- Prebuilt native libraries for every platform, so nothing is compiled during your build.
- Hardware-accelerated encoding and decoding through VideoToolbox on iOS and macOS.
- Android Storage Access Framework (SAF) URIs can be used directly as inputs and outputs.
- iOS and macOS integrate through Swift Package Manager, with checksum-pinned XCFrameworks, or through CocoaPods, which can check the download's SHA-256.
Installation #
Requires Flutter 3.41 or later.
dependencies:
ffmpeg_kit_flutter_new_converter_gpl: ^1.0.0
import 'package:ffmpeg_kit_flutter_new_converter_gpl/ffmpeg_kit.dart';
Quick start #
import 'package:ffmpeg_kit_flutter_new_converter_gpl/ffmpeg_kit.dart';
final session = await FFmpegKit.execute('-i input.mp4 -c:v mpeg4 output.mp4');
final returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
// Success
} else if (ReturnCode.isCancel(returnCode)) {
// Cancelled
} else {
// Failed: inspect await session.getLogs()
}
Choosing a package #
The plugin is published as nine packages that share the same Dart API and differ only in the native libraries they bundle. Choose the smallest one that covers the codecs you need. The GPL-licensed codecs (x264, x265, xvidcore, vid.stab) are only included in the -gpl packages.
| Package | Contents |
|---|---|
_min |
Smallest build, core FFmpeg only |
_min_gpl |
Minimal plus GPL codecs (x264, x265, xvid, vid.stab) |
_https |
Adds TLS (gnutls) for https:// inputs |
_https_gpl |
HTTPS plus GPL codecs |
_audio |
Audio codecs (mp3, opus, vorbis, speex and others) |
_video |
Video codecs (dav1d, vpx, theora, webp and others) |
_converter_gpl (this package) |
Converting between common formats: x264, x265, lame, opus, vorbis, vpx, webp and dav1d (GPL) |
_full |
Every library except the GPL codecs |
ffmpeg_kit_flutter_new |
Every library, including the GPL codecs |
Enabled libraries #
The table lists the system and external libraries enabled in each package's Android, iOS and macOS builds. The Windows and Linux bundles are built against MSYS2 and system packages respectively; the Windows bundle lists every DLL it contains in LICENSES/NOTICE.txt.
| min | min-gpl | https | https-gpl | audio | video | converter-gpl | full | full-gpl | |
|---|---|---|---|---|---|---|---|---|---|
| external libraries | - | vid.stab x264 x265 xvidcore |
gmp gnutls |
gmp gnutls vid.stab x264 x265 xvidcore |
lame libilbc libvorbis opencore-amr opus shine soxr speex twolame vo-amrwbenc |
dav1d fontconfig freetype fribidi kvazaar libass libiconv libtheora libvpx libwebp snappy zimg |
dav1d lame libiconv libvorbis libvpx libwebp opus x264 x265 |
chromaprint dav1d fontconfig freetype fribidi gmp gnutls kvazaar lame libaom libass libiconv libilbc libtheora libvorbis libvpx libwebp libxml2 opencore-amr openh264 openssl opus shine snappy soxr speex srt tesseract twolame vo-amrwbenc zimg |
chromaprint dav1d fontconfig freetype fribidi gmp gnutls kvazaar lame libaom libass libiconv libilbc libtheora libvorbis libvpx libwebp libxml2 opencore-amr openh264 openssl opus rubberband shine snappy soxr speex srt tesseract twolame vid.stab vo-amrwbenc x264 x265 xvidcore zimg |
| android system libraries | zlib MediaCodec |
||||||||
| ios system libraries | bzip2 AudioToolbox AVFoundation iconv zlib |
||||||||
| ios VideoToolbox | VideoToolbox | VideoToolbox | - | - | - | - | VideoToolbox | VideoToolbox | VideoToolbox |
| macos system libraries | bzip2 AudioToolbox AVFoundation Core Image iconv OpenCL OpenGL VideoToolbox zlib |
||||||||
Platform support #
| Platform | Minimum version | Architectures |
|---|---|---|
| Android | API 24 | arm-v7a, arm-v7a-neon, arm64-v8a, x86, x86_64 |
| iOS | 15.0 | arm64 (device); arm64, x86_64 (simulator), shipped as .xcframework |
| macOS | 11.0 | arm64, x86_64 |
| Windows | 10 | x86_64 |
| Linux | - | x86_64 |
iOS and macOS #
With Swift Package Manager, Xcode downloads the XCFrameworks and checks them against the checksums pinned in the package.
With CocoaPods, pod install downloads the prebuilt frameworks as a zip from the 8.1.3-converter-gpl release the first time it installs the plugin. To have that download checked, set FFMPEG_KIT_IOS_SHA256 (or FFMPEG_KIT_MACOS_SHA256) to the zip's SHA-256 before running pod install. The release page shows the SHA-256 of each file. A zip with another SHA-256 is refused and nothing is installed. Frameworks that are already installed are not downloaded or checked again. A plugin version with new frameworks downloads a different zip, so update the value when you upgrade to one.
If your network cannot reach GitHub, mirror the zip and set FFMPEG_KIT_IOS_URL (or FFMPEG_KIT_MACOS_URL) to the mirror's address. The SHA-256 check applies to a mirror too.
With either package manager, the frameworks come with their dSYMs, so Xcode puts them in your app's archives and crash reports symbolicate inside FFmpeg.
Windows #
Prebuilt FFmpeg 8.1.3 libraries are downloaded into your application's build directory the first time you build. To build against a locally built bundle instead, set FFMPEGKIT_LOCAL_DIR (as an environment variable or a CMake cache variable) to the bundle directory before running flutter run or flutter build windows.
The bundle's license notices are installed next to your executable in licenses/ffmpeg_kit_flutter_new_converter_gpl/. See License.
Linux #
Prebuilt FFmpeg 8.1.3 libraries are downloaded at build time in the same way as on Windows, and FFMPEGKIT_LOCAL_DIR works the same way. In addition to Flutter's standard Linux prerequisites (clang, cmake, ninja-build, pkg-config, libgtk-3-dev), the plugin requires libjson-glib-dev:
sudo apt-get install libjson-glib-dev # Debian, Ubuntu
sudo dnf install json-glib-devel # Fedora
Usage #
Execute a command and read the result
import 'package:ffmpeg_kit_flutter_new_converter_gpl/ffmpeg_kit.dart';
FFmpegKit.execute('-i file1.mp4 -c:v mpeg4 file2.mp4').then((session) async {
final returnCode = await session.getReturnCode();
if (ReturnCode.isSuccess(returnCode)) {
// Success
} else if (ReturnCode.isCancel(returnCode)) {
// Cancelled
} else {
// Failed
}
});
Inspect a session
FFmpegKit.execute('-i file1.mp4 -c:v mpeg4 file2.mp4').then((session) async {
final sessionId = session.getSessionId();
final command = session.getCommand();
final state = await session.getState();
final returnCode = await session.getReturnCode();
final duration = await session.getDuration();
final output = await session.getOutput();
final logs = await session.getLogs();
final statistics = await (session as FFmpegSession).getStatistics();
});
Run asynchronously with callbacks
FFmpegKit.executeAsync('-i file1.mp4 -c:v mpeg4 file2.mp4', (Session session) async {
// Called when the session completes
}, (Log log) {
// Called for each log line
}, (Statistics statistics) {
// Called when the session reports statistics
});
Read media information with FFprobe
FFprobeKit.getMediaInformation('<file path or url>').then((session) async {
final information = await session.getMediaInformation();
});
Cancel sessions
FFmpegKit.cancel(); // Cancel all sessions
FFmpegKit.cancel(sessionId); // Cancel one session
Android: Storage Access Framework (SAF)
// Read from a document
FFmpegKitConfig.selectDocumentForRead('*/*').then((uri) {
FFmpegKitConfig.getSafParameterForRead(uri!).then((safUrl) {
FFmpegKit.executeAsync("-i ${safUrl!} -c:v mpeg4 file2.mp4");
});
});
// Write to a document
FFmpegKitConfig.selectDocumentForWrite('video.mp4', 'video/*').then((uri) {
FFmpegKitConfig.getSafParameterForWrite(uri!).then((safUrl) {
FFmpegKit.executeAsync("-i file1.mp4 -c:v mpeg4 ${safUrl}");
});
});
Global callbacks and fonts
FFmpegKitConfig.enableLogCallback((log) { final message = log.getMessage(); });
FFmpegKitConfig.enableStatisticsCallback((statistics) { final size = statistics.getSize(); });
FFmpegKitConfig.setFontDirectoryList(["/system/fonts", "/System/Library/Fonts", "<folder with fonts>"]);
License #
The plugin is licensed under LGPL 3.0. This package also includes GPL 3.0 components (x264, x265), so an application that uses it is distributed under GPL 3.0.
FFmpeg and the bundled third-party libraries keep their own licenses. On Windows, the prebuilt bundle includes a LICENSES/ directory with the FFmpeg and FFmpegKit license texts, and a NOTICE.txt that lists every bundled DLL with its license, version and a link to its exact source. The plugin installs it into licenses/ffmpeg_kit_flutter_new_converter_gpl/ next to your executable; ship that directory with your application. The other platforms' downloads carry the same kind of LICENSES/ directory, whose NOTICE.txt lists FFmpeg, FFmpegKit and each library compiled into the binaries: at the root of the Android AAR and of the iOS and macOS zips on the GitHub release, and in ffmpeg-kit/LICENSES/ in the Linux bundle. The plugin doesn't copy those into your app.
Support #
- Questions and discussion: Discord
- Bug reports and feature requests: GitHub issues
- Support development: Buy Me a Coffee