video_compress_kit_platform_interface
The platform interface package for video_compress_kit.
This package defines the abstract VideoCompressKitPlatform class that all
platform implementations must implement, plus the shared Dart types used
across the entire federated plugin.
For app developers
You should not depend on this package directly. Instead, use the app-facing
video_compress_kit package
which re-exports all the types you need.
Shared Types
Video types
| Type | Description |
|---|---|
VideoQuality |
Preset compression quality with resolution caps and bitrate estimation (veryLow, low, medium, high, veryHigh) |
CompressionConfig |
Full configuration for a video compression operation |
CompressionResult |
Result data returned after compression |
MediaInfo |
Metadata about a video file (width, height, duration, bitrate, etc.) |
Image types
| Type | Description |
|---|---|
ImageFormat |
Output image format enum: jpeg, png, webp |
ImageCompressionConfig |
Configuration for image compression (quality, max dimensions, format, EXIF) |
ImageCompressionResult |
Result data returned after image compression |
Advanced codec types
| Type | Description |
|---|---|
H264Profile |
H.264 encoding profile: baseline, main, high |
BitrateMode |
Bitrate mode: vbr, cbr, cq (constant quality) |
ColorStandard |
Color space standard: bt601, bt709 |
Platform Interface Contract
VideoCompressKitPlatform — abstract methods
| Method | Signature | Description |
|---|---|---|
compressVideo |
Future<CompressionResult> compressVideo(String path, {required String sessionId, CompressionConfig config}) |
Compress a video with per-session tracking |
compressImage |
Future<ImageCompressionResult> compressImage(String path, {ImageCompressionConfig config}) |
Compress an image (JPEG/PNG/WebP) |
getMediaInfo |
Future<MediaInfo> getMediaInfo(String path) |
Retrieve video metadata |
getThumbnail |
Future<Uint8List?> getThumbnail(String path, {int quality, int position}) |
Extract a single JPEG frame |
cancelCompression |
Future<void> cancelCompression({String? sessionId}) |
Cancel one or all compression sessions |
compressionProgress |
Stream<Map<String, dynamic>> get compressionProgress |
Progress stream with sessionId and progress (0.0–1.0) |
Key design decisions
- Per-session model:
compressVideo()requires asessionIdstring. Progress events include bothsessionIdandprogressin aMap<String, dynamic>, allowing callers to demultiplex progress for concurrent sessions. - Cancel granularity:
cancelCompression(sessionId: 'x')cancels a specific session;cancelCompression()(no argument) cancels all active sessions. - Image compression: Separate method
compressImage()with its own config/result types, keeping video and image APIs cleanly separated.
CompressionConfig fields
| Field | Type | Default | Description |
|---|---|---|---|
quality |
VideoQuality |
medium |
Quality preset |
bitrate |
int? |
null |
Override bitrate in bps |
width |
int? |
null |
Override output width |
height |
int? |
null |
Override output height |
frameRate |
int? |
null |
Override frame rate |
includeAudio |
bool |
true |
Include audio track |
deleteOrigin |
bool |
false |
Delete original file |
outputPath |
String? |
null |
Custom output path |
h264Profile |
H264Profile? |
null |
H.264 profile (baseline/main/high) |
bitrateMode |
BitrateMode? |
null |
Bitrate mode (vbr/cbr/cq) |
cqQuality |
int? |
null |
CQ quality value (0–100) |
colorStandard |
ColorStandard? |
null |
Color space (bt601/bt709) |
faststart |
bool |
false |
Moov atom at front (both platforms — iOS native, Android custom post-processor) |
ImageCompressionConfig fields
| Field | Type | Default | Description |
|---|---|---|---|
quality |
int |
80 |
Output quality (1–100). Ignored for PNG |
maxWidth |
int? |
null |
Max output width (scales proportionally) |
maxHeight |
int? |
null |
Max output height (scales proportionally) |
format |
ImageFormat |
jpeg |
Output format: jpeg, png, webp |
keepExif |
bool |
false |
Preserve EXIF metadata |
outputPath |
String? |
null |
Custom output path |
For plugin implementors
If you are building a platform implementation (e.g. video_compress_kit_web):
- Add this package as a dependency.
- Extend
MethodChannelVideoCompressKit(orVideoCompressKitPlatformdirectly if you don't use method channels). - Implement all abstract methods listed above.
- Register your implementation via
registerWith()and list it in yourpubspec.yamlunderflutter.plugin.platforms.
Method channel protocol
The default MethodChannelVideoCompressKit uses:
| Channel | Type | Purpose |
|---|---|---|
com.ikolvi.video_compress_kit |
MethodChannel |
All request/response calls |
com.ikolvi.video_compress_kit/progress |
EventChannel |
Progress stream |
Method calls
| Method name | Arguments | Returns |
|---|---|---|
compressVideo |
{path, sessionId, ...config.toMap()} |
Map → CompressionResult |
compressImage |
{path, ...imageConfig.toMap()} |
Map → ImageCompressionResult |
getMediaInfo |
{path} |
Map → MediaInfo |
getThumbnail |
{path, quality, position} |
Uint8List? |
cancelCompression |
{sessionId?} |
void |
Event channel format
Progress events are Map<String, dynamic> with:
sessionId—Stringidentifying the compression sessionprogress—doublefrom0.0to1.0
For backward compatibility, bare
doublevalues are also accepted and mapped to{'sessionId': 'unknown', 'progress': value}.
See the federated plugin guide for full details.
License
MIT — see LICENSE.
Libraries
- video_compress_kit_platform_interface
- The platform interface for the video_compress_kit plugin.