Skip to content

Repository files navigation

video_compress

All ContributorsPlatformPub PackageLicense: MITForksStars

Compress videos, remove audio, manipulate thumbnails, and make your video compatible with all platforms through this lightweight and efficient library. 100% native code was used, we do not use FFMPEG as it is very slow, bloated and the GNU license is an obstacle for commercial applications. In addition, google chrome uses VP8/VP9, safari uses h264, and most of the time, it is necessary to encode the video in two formats, but not with this library. All video files are encoded in an MP4 container with AAC audio that allows 100% compatibility with safari, mozila, chrome, android and iOS.

Works on ANDROID and IOS.

Table of Contents

Lets Get Started

1. Depend on it

Add this to your package's pubspec.yaml file:

dependencies:
video_compress: ^2.1.0

2. Install it

You can install packages from the command line:

with pub:

$ pub get

3. Import it

Now in your Dart code, you can use:

import'package:video_compress/video_compress.dart';

How to use

Imports

import'package:video_compress/video_compress.dart';

Video compression

MediaInfo mediaInfo =awaitVideoCompress.compressVideo(
path,
quality:VideoQuality.DefaultQuality, deleteOrigin:false, // It's false by default
);

Check compress state

VideoQuality.isCompressing

Get memory thumbnail from VideoPath

final uint8list =awaitVideoCompress.getByteThumbnail(
videopath,
quality:50, // default(100)
position:-1// default(-1)
);

Get File thumbnail from VideoPath

final thumbnailFile =awaitVideoCompress.getFileThumbnail(
videopath,
quality:50, // default(100)
position:-1// default(-1)
);

Get media information

final info =awaitVideoCompress.getMediaInfo(videopath);

delete all cache files

  • Delete all files generated by this will delete all files located at 'video_compress', you shoule ought to know what are you doing.
awaitVideoCompress.deleteAllCache()

Listen the compression progress

class_CompressextendsState<Compress> {
Subscription _subscription;
@overridevoidinitState() {
super.initState();
_subscription =VideoCompress.compressProgress$.subscribe((progress) {
debugPrint('progress: $progress');
});
}
@overridevoiddispose() {
super.dispose();
_subscription.unsubscribe();
}
}

TODO

  • Add the trim video function
  • Add cancel function to Android

Methods

FunctionsParametersDescriptionReturns
getByteThumbnailString path[video path], int quality(1-100)[thumbnail quality], int position[Get a thumbnail from video position]get thumbnail from video pathFuture<Uint8List>
getFileThumbnailString path[video path], int quality(1-100)[thumbnail quality], int position[Get a thumbnail from video position]get thumbnail file from video pathFuture<File>
getMediaInfoString path[video path]get media information from video pathFuture<MediaInfo>
compressVideoString path[video path], VideoQuality quality[compressed video quality], bool deleteOrigin[delete the origin video], int startTime[compression video start time], int duration[compression video duration from start time], bool includeAudio[is include audio in compressed video], int frameRate[compressed video frame rate]compression video at origin video pathFuture<MediaInfo>
cancelCompressionnonecancel compressingFuture<void>
deleteAllCachenoneDelete all files generated by 'video_compress' will delete all files located at 'video_compress'Future<bool>

Subscriptions

SubscriptionsDescriptionStream
compressProgress$Subscribe the compression progress steamdouble progress

Contribute

Contributions are always welcome!

acknowledgment

Inspired by the flutter_ffmpeg library. https://github.com/rurico/flutter_video_compress

Contributors ✨

Thanks goes to these wonderful people:


khainhero
🚧

Andres Gutierrez

🚧

Jonny Borges

💻

Tibout Shaik
🚧

Marco A. Braghim
🚧

ppornkitpras-agoda

🚧

Rafał Płonka

🚧

Yaniv Shaked

🚧

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Compress videos, remove audio, manipulate thumbnails, and make your video compatible with all platforms through this lightweight and efficient library.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages