flutter_video_compress 0.3.4 copy "flutter_video_compress: ^0.3.4" to clipboard
flutter_video_compress: ^0.3.4 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.detail

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

post_install do |installer|
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['ENABLE_BITCODE'] = 'NO'
      config.build_settings['SWIFT_VERSION'] = '5.0' # <--- add this
    end
  end
end

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>]
convertVideoToGif String [path], int [startTime](from 0 start), int [endTime], int [duration] converts provided video to a gif [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,
);

Converts provided video to a gif.

final file = await _flutterVideoCompress.convertVideoToGif(
  videoFile.path,
  startTime: 0,
  duration: 5,
);
print(file.path);

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
78%
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