Video, image and audio processing via native platform code.
Only Apple (iOS & macOS) support is implemented via native code yet.
Flutter plugin for advanced media manipulation using native platform code. Supported media types are video
, audio
and image
.
Platform | Framework |
---|---|
Apple | MediaToolSwift |
Android | MediaCodec* |
Windows & Linux | OpenCL* |
* Pull requests with implementation of MediaToolPlatform
are welcome!
Video: H.264
, H.265/HEVC
and ProRes
.
Audio: AAC
, Opus
and FLAC
.
// Compress video file
final task = VideoTool.compress(
id: id, // unique id
path: path,
destination: destination,
// Video
videoSettings: const VideoSettings(
codec: VideoCodec.h264,
bitrate: 2000000, // 2 Mbps
size: Size(1280.0, 1280.0), // size to fit in
// quality, frame rate, atd.
),
// Audio
skipAudio: false,
audioSettings: const AudioSettings(
codec: AudioCodec.opus,
bitrate: 96000, // 96 Kbps
// sample rate, quality, atd.
),
// Metadata and file options
skipMetadata: false,
overwrite: true,
deleteOrigin: false
);
// State notifier
task.events.listen(print);
// Cancellation
task.cancel();
JPEG
PNG
and APNG
GIF
TIFF
BMP
WEBP
HEIF
// Convert image file
final metadata = await ImageTool.compress(
path: path,
destination: destination,
settings: const ImageSettings(
format: ImageFormat.png,
size: Size(1280.0, 1280.0),
crop: false, // crop or fit
// frame rate, quality, alpha channel, background color, atd.
),
skipMetadata: false,
overwrite: true,
deleteOrigin: false
);
AAC
Opus
FLAC
// Compress audio file
final task = AudioTool.compress(
id: id, // unique id
path: path,
destination: destination,
settings: const AudioSettings(
codec: AudioCodec.opus,
bitrate: 96000, // 96 Kbps
// sample rate, quality, atd.
),
skipMetadata: false,
overwrite: true,
deleteOrigin: false
);
// State notifier
task.events.listen(print);
// Cancellation
task.cancel();
Each plugin methods which run platform code do support multiple parallel executions, each of execution has it's own progress, cancellation and error handling. Main tests stored at integration_test.
Plugin Name | Time |
---|---|
media_tool_darwin | 1x |
video_compress | 1x |
light_compressor | 1.5-2x |
media_tool_ffmpeg | 8-12x |
Video tests were executed on macOS (Apple Silicon) using H.264/AAC/MP4 with 1280x720 and 1920x1080 resolutions.
Plugin Name | Time | |
---|---|---|
media_tool_darwin | 1x | / up to 3x speed up on sequential calls (1/3x) / |
media_tool_ffmpeg | 3-5x | / no speed up on sequential calls / |
image | 10x |
Image tests were executed on macOS (Apple Silicon) using PNG and JPEG.
The Plugin is licensed under the MIT. The platform implementations may have their own licenses: