flutter_video_compress 0.3.3+3 copy "flutter_video_compress: ^0.3.3+3" to clipboard
flutter_video_compress: ^0.3.3+3 copied to clipboard

outdated

Compressed video generates a new path, keep the source video or delete it. provide get video information or get thumbnail of the video file. Android used ffmpeg, IOS not.

flutter_video_compress #

Compressed video generates a new path, keep the source video or delete it. provide get video information or get thumbnail of the video file.

pub version license

languages #

english 简体中文 日本語

Before Android installation #

If your program 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"
                }
            }
        }
    }
}

Before IOS installation #

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

target 'Runner' do
  use_frameworks! # <- add this line

Methods #

function parameter description return
getThumbnail String [path], int [quality](1-100), int [position] get thumbnail from [path] [Future<Uint8List>]
getThumbnailWithFile String [path], int [quality](1-100), int [position] get thumbnail file from [path] [Future<File>]
getMediaInfo String [path] get media information from [path] [Future<MediaInfo>]
startCompress String [path], VideoQuality [quality] ,bool [deleteOrigin] compress video at [path] [Future<MediaInfo>]
stopCompress [none] stop compressing the file that is currently being compressed. [Future<void>]

Subscriptions #

subscription description stream
compressProgress$ Subscribe the conversion progress steam double [progress]

Usage #

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

dependencies:
  flutter_video_compress: ^0.3.x

Creating instance.

FlutterVideoCompress _flutterVideoCompress = FlutterVideoCompress();

Get thumbnail by video file

final uint8list = await _flutterVideoCompress.getThumbnail(
  file.path,
  quality: 50,
);

Get thumbnail file by video file

final thumbnailFile = await _flutterVideoCompress.getThumbnailWithFile(
  file.path,
  quality: 50,
);

Get media information

Currently only supports video

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

Compression Video

Compatible with ios in Android and web after compression

final info = await _flutterVideoCompress.startCompress(
  file.path,
  deleteOrigin: true,
);
print(info.toJson());

Check Compressing state

_flutterVideoCompress.isCompressing

Stop compression

Android will print InterruptedException, but does not affect the use

await _flutterVideoCompress.stopCompress()

Subscribe the conversion progress steam

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

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

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

Notice #

If you find that the size of the apk is significantly increased after importing the plugin, it may be due to the following reasons:

  • exclude x86 related files (./assets)

  • This library does not use ffprobe, only uses ffmpeg, but the application still has ffprobe, so it needs to be excluded (asssets/arm or assets/x86)

add this config in build.gradle:

  • Do not 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 up for detail

86
likes
0
pub points
73%
popularity

Publisher

unverified uploader

Compressed video generates a new path, keep the source video or delete it. provide get video information or get thumbnail of the video file. Android used ffmpeg, IOS not.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on flutter_video_compress