All Projects → rurico → Flutter_video_compress

rurico / Flutter_video_compress

Licence: mit
Generate a new file by compressed video, and provide metadata. Get video thumbnail from a video path, supports JPEG/GIF. To reduce app size not using FFmpeg in IOS.

Programming Languages

dart
5743 projects

Projects that are alternatives of or similar to Flutter video compress

Youtube player
A flutter plugin to play Youtube Videos without API Key in range of Quality(144p, 240p,360p,480p,720p and 1080p).
Stars: ✭ 118 (-18.62%)
Mutual labels:  flutter-plugin
Background location
Flutter background location plugin for Android and iOS
Stars: ✭ 127 (-12.41%)
Mutual labels:  flutter-plugin
Modal progress hud
A simple modal progress HUD (heads-up display, or progress indicator) for flutter
Stars: ✭ 137 (-5.52%)
Mutual labels:  flutter-plugin
Esys Flutter Share
A Flutter plugin for sharing files & text with other applications.
Stars: ✭ 119 (-17.93%)
Mutual labels:  flutter-plugin
Nautilus
阿里百川电商Flutter插件。
Stars: ✭ 123 (-15.17%)
Mutual labels:  flutter-plugin
Flutter android
Android bindings plugin for Flutter.
Stars: ✭ 131 (-9.66%)
Mutual labels:  flutter-plugin
Edge detection
This is a flutter plugin to detect edges in a live camera, take the picture of detected edges object, crop it, and save.
Stars: ✭ 116 (-20%)
Mutual labels:  flutter-plugin
Ratemyapp
This plugin allows to kindly ask users to rate your app if custom conditions are met (eg. install time, number of launches, etc...).
Stars: ✭ 143 (-1.38%)
Mutual labels:  flutter-plugin
Plugins
go-flutter implementations for popular Flutter plugins
Stars: ✭ 125 (-13.79%)
Mutual labels:  flutter-plugin
Analog clock
⌚️Analog Clock widget for Flutter ⏰
Stars: ✭ 136 (-6.21%)
Mutual labels:  flutter-plugin
Flutteryoutube
Flutter Plugin to play youtube Videos
Stars: ✭ 120 (-17.24%)
Mutual labels:  flutter-plugin
Flutter Concentric Transition
A Flutter plugin to create views using concentric transition effect.
Stars: ✭ 122 (-15.86%)
Mutual labels:  flutter-plugin
Mediumclapflutter
A Custom Floating Action Button (FAB) library like clapping effect on Medium
Stars: ✭ 133 (-8.28%)
Mutual labels:  flutter-plugin
Flutter contacts
A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
Stars: ✭ 119 (-17.93%)
Mutual labels:  flutter-plugin
Flutter alipay
A flutter plugin to use alipay.
Stars: ✭ 137 (-5.52%)
Mutual labels:  flutter-plugin
Flutter Adaptivecards
AdaptiveCards for Flutter 🐦
Stars: ✭ 117 (-19.31%)
Mutual labels:  flutter-plugin
Flutter credit card
A credit card widget for Flutter application.
Stars: ✭ 126 (-13.1%)
Mutual labels:  flutter-plugin
Wififlutter
Plugin Flutter which can handle WiFi connections (AP, STA)
Stars: ✭ 142 (-2.07%)
Mutual labels:  flutter-plugin
Flutter xupdate
A Flutter plugin for XUpdate(Android Version Update Library)
Stars: ✭ 138 (-4.83%)
Mutual labels:  flutter-plugin
K chart
Maybe it is the best k chart in Flutter.
Stars: ✭ 134 (-7.59%)
Mutual labels:  flutter-plugin

flutter_video_compress

Generate a new path by compressed video, Choose to keep the source video or delete it by a parameter. Get video thumbnail from a video path and provide video information. Easy to deal with compressed video. Considering reduce application size is not using FFmpeg in IOS.

pub version license android min Sdk Version ios min target

flutter compress video

languages

English 简体中文 日本語

Usage

Installing add flutter_video_compress as a dependency in your pubspec.yaml file.

dependencies:
  flutter_video_compress: ^0.3.x

Create an instance

final _flutterVideoCompress = FlutterVideoCompress();

Get thumbnail from video path

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

Get thumbnail file from video path

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

Convert video to a gif

final file = await _flutterVideoCompress.convertVideoToGif(
  videoFile.path,
  startTime: 0, // default(0)
  duration: 5, // default(-1)
  // endTime: -1 // default(-1)
);
debugPrint(file.path);

Get media information

only support video now.

final info = await _flutterVideoCompress.getMediaInfo(file.path);
debugPrint(info.toJson().toString());

Compression Video

Compatible with IOS, Android and Web after compression.

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

Check Compressing state

_flutterVideoCompress.isCompressing

Stop compression

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

await _flutterVideoCompress.cancelCompression()

delete all cache files

Delete all files generated by this will delete all files located at 'flutter_video_compress', you shoule ought to know what are you doing.

await _flutterVideoCompress.deleteAllCache()

Subscribe the compression progress steam

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

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

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

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 'flutter_video_compress' will delete all files located at 'flutter_video_compress' Future<bool>

Subscriptions

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

Notice

If your application is significantly larger after using the plugin, you can reduce the application size in the following way:

  • exclude x86 related files (./assets)

  • This library not use ffprobe, only used ffmpeg, but the application still has ffprobe, so you will need to exclude (asssets/arm or assets/x86)

add this config in build.gradle:

  • Don't use ignoreAssetsPattern "!x86" in debug mode, will crash on the simulator
android {
 ...
 // Reduce your application size with this configuration
 aaptOptions {
     ignoreAssetsPattern "!x86:!*ffprobe"
 }
 
 buildTypes {
 ...
}

look detail

Questions

If your application is not enabled AndroidX, you will need to add the following code to the last line of the android/build.gradle file.

rootProject.allprojects {
    subprojects {
        project.configurations.all {
            resolutionStrategy.eachDependency { details ->
                if (details.requested.group == 'androidx.core' && !details.requested.name.contains('androidx')) {
                    details.useVersion "1.0.1"
                }
            }
        }
    }
}

If your application not support swift, you need to add the following code in ios/Podfile.

target 'Runner' do
  use_frameworks! # <--- add this
  ...
end

look detail

If your application never used a swift plugin before, maybe you would meet the error, you need to add the following code in ios/Podfile.

The 'Pods-Runner' target has transitive dependencies that include static binaries

pre_install do |installer|
  # workaround for https://github.com/CocoaPods/CocoaPods/issues/3289
  Pod::Installer::Xcode::TargetValidator.send(:define_method, :verify_no_static_framework_transitive_dependencies) {}
end

If the above method not work, you report bug of the error repository. The reason is「can't support swift」

look detail

if show error of Regift

  • Regift does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.
pre_install do |installer|
  installer.analysis_result.specifications.each do |s|
      if s.name == 'Regift'
        s.swift_version = '4.0'
      end
  end
end

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
    end
  end
end

Contribute

Contributions are always welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].