# flutter_ffmpeg
FFmpeg plugin for Flutter. Supports iOS and Android.
### 1. Features
- Based on MobileFFmpeg
- Supports
- Both Android and IOS
- FFmpeg `v4.2-dev-x` (master) releases
- `arm-v7a`, `arm-v7a-neon`, `arm64-v8a`, `x86` and `x86_64` architectures on Android
- `armv7`, `armv7s`, `arm64`, `arm64e`, `i386` and `x86_64` architectures on IOS
- 24 external libraries
`fontconfig`, `freetype`, `fribidi`, `gmp`, `gnutls`, `kvazaar`, `lame`, `libaom`, `libass`, `libiconv`, `libilbc`, `libtheora`, `libvorbis`, `libvpx`, `libwebp`, `libxml2`, `opencore-amr`, `opus`, `shine`, `snappy`, `soxr`, `speex`, `twolame`, `wavpack`
- 4 external libraries with GPL license
`vid.stab`, `x264`, `x265`, `xvidcore`
- `zlib` and `MediaCodec` Android system libraries
- `bzip2`, `zlib` IOS system libraries and `AudioToolbox`, `CoreImage`, `VideoToolbox`, `AVFoundation` IOS system frameworks
- Licensed under LGPL 3.0, can be customized to support GPL v3.0
- Includes eight different packages with different external libraries enabled in FFmpeg
|
min |
min-gpl |
https |
https-gpl |
audio |
video |
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 wavpack |
fontconfig freetype fribidi kvazaar libaom libass libiconv libtheora libvpx libwebp snappy |
fontconfig freetype fribidi gmp gnutls kvazaar lame libaom libass libiconv libilbc libtheora libvorbis libvpx libwebp libxml2 opencore-amr opus shine snappy soxr speex twolame wavpack |
fontconfig freetype fribidi gmp gnutls kvazaar lame libaom libass libiconv libilbc libtheora libvorbis libvpx libwebp libxml2 opencore-amr opus shine snappy soxr speex twolame vid.stab wavpack x264 x265 xvidcore |
| android system libraries |
zlib MediaCodec |
| ios system libraries |
zlib AudioToolbox AVFoundation CoreImage VideoToolbox bzip2 |
### 2. Installation
Add `flutter_ffmpeg` as a [dependency in your pubspec.yaml file](https://flutter.io/platform-plugins).
#### 2.1 Packages
Default installation of `FlutterFFmpeg` enables the default package, which is based on `https` package. It is possible
to enable other installed packages using the following steps.
1. Use the following dependency block in your `pubspec.yaml` file.
```
dependencies:
flutter_ffmpeg:
git:
url: git://github.com/tanersener/flutter-ffmpeg.git
ref: v0.1.0
path: packages/flutter_ffmpeg_https
```
2. Set package name in `path: packages/flutter_ffmpeg_` section.
### 3. Using
1. Execute commands.
```
import 'package:flutter_ffmpeg/flutter_ffmpeg.dart';
final FlutterFFmpeg _flutterFFmpeg = new FlutterFFmpeg();
_flutterFFmpeg.execute("-i file1.mp4 -c:v mpeg4 file2.mp4").then((rc) => print("FFmpeg process exited with rc $rc"));
```
2. Check execution output.
```
_flutterFFmpeg.getLastReturnCode().then((rc) => print("Last rc: $rc"));
_flutterFFmpeg.getLastCommandOutput().then((output) => print("Last command output: $output"));
```
3. Stop an ongoing operation.
```
_flutterFFmpeg.cancel();
```
4. Get media information for a file.
```
_flutterFFmpeg.getMediaInformation('').then((info) => print(info));
```
5. List enabled external libraries.
```
_flutterFFmpeg.getExternalLibraries().then((packageList) {
packageList.forEach((value) => print("External library: $value"));
});
```
6. Enable log callback.
```
void logCallback(int level, String message) {
print(message);
}
...
_flutterFFmpeg.enableLogCallback(this.logCallback);
```
7. Enable statistics callback.
```
void statisticsCallback(int time, int size, double bitrate, double speed, int videoFrameNumber, double videoQuality, double videoFps) {
print("Statistics: time: $time, size: $size, bitrate: $bitrate, speed: $speed, videoFrameNumber: $videoFrameNumber, videoQuality: $videoQuality, videoFps: $videoFps");
}
...
_flutterFFmpeg.enableStatisticsCallback(this.statisticsCallback);
```
8. Get last received statistics.
```
_flutterFFmpeg.getLastReceivedStatistics().then((stats) => print(stats));
```
9. Set log level.
```
_flutterFFmpeg.setLogLevel(LogLevel.AV_LOG_WARNING);
```
10. Register custom fonts directory.
```
_flutterFFmpeg.setFontDirectory("");
```
### 4. Versions
#### 4.1 Releases
- `0.1.0` releases is based on `FFmpeg v4.2-dev` and `MobileFFmpeg v4.2.LTS`
### 5. Updates
Refer to [Changelog](CHANGELOG.md) for updates.
### 6. License
This project is licensed under the LGPL v3.0. However, if installation is customized to use a package with `-gpl` postfix (min-gpl, https-gpl, full-gpl) then `FlutterFFmpeg` is subject to the GPL v3.0 license.
Digital assets used in test applications are published in the public domain.
### 7. Contributing
Feel free to submit issues or pull requests.
### 8. See Also
- [FFmpeg](https://www.ffmpeg.org)
- [Mobile FFmpeg Wiki](https://github.com/tanersener/mobile-ffmpeg/wiki)
- [FFmpeg License and Legal Considerations](https://ffmpeg.org/legal.html)