video_compress 0.1.1 copy "video_compress: ^0.1.1" to clipboard
video_compress: ^0.1.1 copied to clipboard

outdated

Light library of video manipulation of Flutter. Compress video, remove audio, get video thumbnail from dart code.

video_compress #

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.

How to use #

VideoCompress videoCompress = VideoCompress();

Get thumbnail from video path

final uint8list = await videoCompress.getThumbnail(
  file.path,
  quality: 50, // default(100)
  position: -1 // default(-1)
);

Get thumbnail file from video path

final thumbnailFile = await videoCompress.getThumbnailWithFile(
  file.path,
  quality: 50, // default(100)
  position: -1 // default(-1)
);

Get media information

final info = await videoCompress.getMediaInfo(file.path);

Compression Video

Compatible with IOS, Android and Web after compression.

final info = await videoCompress.compressVideo(
  file.path,
  quality: VideoQuality.DefaultQuality, // default(VideoQuality.DefaultQuality)
  deleteOrigin: false, // default(false)
);

Check Compressing state

videoCompress.isCompressing

Stop compression

Will print InterruptedException in android, but not affect to use.

await videoCompress.cancelCompression()

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.

await videoCompress.deleteAllCache()

Subscribe the compression progress steam

class ... extends State<MyApp> {
  Subscription _subscription;

  @override
  void initState() {
    super.initState();
    _subscription =
        videoCompress.compressProgress$.subscribe((progress) {
      debugPrint('progress: $progress');
    });
  }

  @override
  void dispose() {
    super.dispose();
    _subscription.unsubscribe();
  }
}

TODO #

  • Finish methods on android.
  • Add the trim function

Methods #

Functions Parameters Description Returns
getThumbnail String path[video path], int quality(1-100)[thumbnail quality], int position[Get a thumbnail from video position] get thumbnail from video path Future<Uint8List>
getThumbnailWithFile String path[video path], int quality(1-100)[thumbnail quality], int position[Get a thumbnail from video position] get thumbnail file from video path Future<File>
convertVideoToGif String path[video path], int startTime(from 0 start)[convert video to gif start time], int endTime[convert video to gif end time], int duration[convert video to gif duration from start time] convert video to gif from video path Future<File>
getMediaInfo String path[video path] get media information from video path Future<MediaInfo>
compressVideo String 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 path Future<MediaInfo>
cancelCompression none cancel compressing Future<void>
deleteAllCache none Delete all files generated by 'video_compress' will delete all files located at 'video_compress' Future<bool>

Subscriptions #

Subscriptions Description Stream
compressProgress$ Subscribe the compression progress steam double progress

Contribute #

Contributions are always welcome!

acknowledgment #

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

640
likes
0
pub points
99%
popularity

Publisher

verified publishergetx.site

Light library of video manipulation of Flutter. Compress video, remove audio, get video thumbnail from dart code.

Homepage

License

unknown (license)

Dependencies

flutter

More

Packages that depend on video_compress