video_compress_kit_platform_interface 0.0.4 copy "video_compress_kit_platform_interface: ^0.0.4" to clipboard
video_compress_kit_platform_interface: ^0.0.4 copied to clipboard

A common platform interface for the video_compress_kit plugin.

video_compress_kit_platform_interface #

pub package License: MIT

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 a sessionId string. Progress events include both sessionId and progress in a Map<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):

  1. Add this package as a dependency.
  2. Extend MethodChannelVideoCompressKit (or VideoCompressKitPlatform directly if you don't use method channels).
  3. Implement all abstract methods listed above.
  4. Register your implementation via registerWith() and list it in your pubspec.yaml under flutter.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()} MapCompressionResult
compressImage {path, ...imageConfig.toMap()} MapImageCompressionResult
getMediaInfo {path} MapMediaInfo
getThumbnail {path, quality, position} Uint8List?
cancelCompression {sessionId?} void

Event channel format

Progress events are Map<String, dynamic> with:

  • sessionIdString identifying the compression session
  • progressdouble from 0.0 to 1.0

For backward compatibility, bare double values are also accepted and mapped to {'sessionId': 'unknown', 'progress': value}.

See the federated plugin guide for full details.

License #

MIT — see LICENSE.

0
likes
150
points
--
downloads

Publisher

verified publisherikolvi.com

Weekly Downloads

A common platform interface for the video_compress_kit plugin.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on video_compress_kit_platform_interface