Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

flutter_compressed video

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

flutter_video compress

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

# -----insert code start-----
pre_install do |installer|
  installer.analysis_result.specifications.each do |s|
      if s.name == 'regift'
        s.swift_version = '4.0'
    # elsif s.name == 'other-plugin'
    #   s.swift_version = '5.0'
    # else
    #   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
# -----insert code 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>]
compressvideo string [path], videoquality [quality], bool [deleteorigin], int [starttime], int [duration], bool [includeaudio], bool [framerate] compress video at [path] [future<mediainfo>]
cancelcompression [none] stop compressing the file that is currently being compressed. [future<void>]
deleteallcache [none] delete the cache, please do not put other things in the folder of this plugin, it will be cleared [future<bool>]

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.

final _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.compressvideo(
  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.cancelcompression()

delete all cache file

delete all the files generated by this plugin, i think you ought to know what you are doing.

await _fluttervideocompress.deleteallcache()

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 compressed video

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 usesffmpeg, 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


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD


Download this source code for
5 USD

Comments are closed.