• Stars
    star
    209
  • Rank 181,880 (Top 4 %)
  • Language
    Swift
  • License
    MIT License
  • Created about 4 years ago
  • Updated about 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

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, IOS and desktop (just MacOS for now).

Table of Contents

Lets Get Started

1. Depend on it

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

dependencies:
  video_compress: ^3.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 = await VideoCompress.compressVideo(
  path,
  quality: VideoQuality.DefaultQuality, 
  deleteOrigin: false, // It's false by default
);

Check compress state

VideoQuality.isCompressing

Get memory thumbnail from VideoPath

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

Get File thumbnail from VideoPath

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

Get media information

final info = await VideoCompress.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.
await VideoCompress.deleteAllCache()

Listen the compression progress

class _Compress extends State<Compress> {

  Subscription _subscription;

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

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

TODO

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

Methods

Functions Parameters Description Returns
getByteThumbnail 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>
getFileThumbnail 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>
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

More Repositories

1

getx

Open screens/snackbars/dialogs/bottomSheets without context, manage states and inject dependencies easily with Get.
Dart
9,842
star
2

get_cli

Official Getx CLI
Dart
564
star
3

get_server

A backend server that makes it possible to program with Flutter syntax and reuse existing code
Dart
466
star
4

get_storage

A fast, extra light and synchronous key-value storage to Get framework
Dart
324
star
5

readmore

A Flutter plugin than allow expand and collapse text dynamically
Dart
209
star
6

flutter_state_managers

A repository that allows you to analyze size, performance, and metrics of Flutter state management approaches
Dart
70
star
7

getx-community

A collaborative repository of GetX usage examples.
35
star
8

easy

The easiest state manager for Flutter.
Dart
19
star
9

getsocket

Dart
18
star
10

getstream

GetStream is the lightest and most performative way of working with events at Dart.
Dart
18
star
11

bloc_boilerplate

A library that contains a well-defined bloc pattern, showing how easy it is to make API-REST requests and error handling using BLoC.
Dart
16
star
12

flutter_web_responsive

A Beauty and responsive flutter web concept
Dart
16
star
13

dart-server-nano

A light, fast, and friendly server written in Dart.
Dart
15
star
14

get_test

A package to facilitate unit tests with Getx
Dart
12
star
15

jonataslaw

10
star
16

corona_virus

Corona virus application using GET. Cases and deaths by country.
Dart
9
star
17

media_utils

An easy helper class to flutter with many support formats. Suport local and web files.
Dart
7
star
18

server_nano

A fast and lightweight HTTP server implementation in Rust.
Rust
5
star
19

picker

flutter plugin for selecting images from the Android and iOS, taking new pictures with the camera and saves photos/videos on Gallery
Objective-C
5
star
20

GameJAM2024

5
star
21

parse-route

A dart route parser package with support to params, urlParams, and wildcards routes
HTML
4
star
22

ikeyboard

A plugin that brings native iOS keyboard behavior to Flutter.
Dart
4
star
23

poprize-plugin-vite

JavaScript
2
star
24

whatsapp_flutter_web

Whatsapp Web messages clone using Flutter Web and Hasura
Dart
2
star
25

photoeditor

A library that lets you apply filters and effects to photos from your device's gallery or camera (android and iOS).
2
star
26

questioning-dataset

A dataset of questions/answers to fine tune IA models
Python
1
star
27

router_matcher

A rust router parser
Rust
1
star