video_trimmer
A Flutter package for trimming videos.
Features
- Customizable video trimmer
- Video playback control
- Retrieving and storing video file
Also, supports conversion to GIF.
TRIM EDITOR
EXAMPLE APP
CUSTOMIZABLE VIDEO EDITOR
Usage
- Add the dependency
video_trimmer
to your pubspec.yaml file.
Android
-
Go to
<project root>/android/app/build.gradle
and set the properminSdkVersion
, 24 for Main Release or 16 for LTS Release.Refer to the FFmpeg Release section.
-
Go to
<project root>/android/build.gradle
and add the following line:Replace the
<package name>
with a proper package name from the Packages List section.
iOS
-
Add the following keys to your Info.plist file, located in
<project root>/ios/Runner/Info.plist
:<key>NSCameraUsageDescription</key> <string>Used to demonstrate image picker plugin</string> <key>NSMicrophoneUsageDescription</key> <string>Used to capture audio for image picker plugin</string> <key>NSPhotoLibraryUsageDescription</key> <string>Used to demonstrate image picker plugin</string>
-
Set the platform version in
ios/Podfile
, 11.0 for Main Release or 9.3 for LTS Release.Refer to the FFmpeg Release section.
platform :ios, '<version>'
-
[Flutter >= 1.20.x] Edit
ios/Podfile
and add the following block beforetarget 'Runner' do
section:def flutter_install_ios_plugin_pods(ios_application_path = nil) # defined_in_file is set by CocoaPods and is a Pathname to the Podfile. ios_application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file) raise 'Could not find iOS application path' unless ios_application_path # Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # referring to absolute paths on developers' machines. symlink_dir = File.expand_path('.symlinks', ios_application_path) system('rm', '-rf', symlink_dir) # Avoid the complication of dependencies like FileUtils. symlink_plugins_dir = File.expand_path('plugins', symlink_dir) system('mkdir', '-p', symlink_plugins_dir) plugins_file = File.join(ios_application_path, '..', '.flutter-plugins-dependencies') plugin_pods = flutter_parse_plugins_file(plugins_file) plugin_pods.each do |plugin_hash| plugin_name = plugin_hash['name'] plugin_path = plugin_hash['path'] if (plugin_name && plugin_path) symlink = File.join(symlink_plugins_dir, plugin_name) File.symlink(plugin_path, symlink) if plugin_name == 'flutter_ffmpeg' pod 'flutter_ffmpeg/<package name>', :path => File.join('.symlinks', 'plugins', plugin_name, 'ios') else pod plugin_name, :path => File.join('.symlinks', 'plugins', plugin_name, 'ios') end end end end
Replace the
<package name>
with a proper package name from the Packages List section. -
[Flutter < 1.20.x] Edit
ios/Podfile
file and modify the default# Plugin Pods
block as follows.# Prepare symlinks folder. We use symlinks to avoid having Podfile.lock # referring to absolute paths on developers' machines. system('rm -rf .symlinks') system('mkdir -p .symlinks/plugins') plugin_pods = parse_KV_file('../.flutter-plugins') plugin_pods.each do |name, path| symlink = File.join('.symlinks', 'plugins', name) File.symlink(path, symlink) if name == 'flutter_ffmpeg' pod name+'/<package name>', :path => File.join(symlink, 'ios') else pod name, :path => File.join(symlink, 'ios') end end
Replace the
<package name>
with a proper package name from the Packages List section.
FFmpeg Release
In reference to the releases specified in the flutter_ffmpeg package.
Main Release | LTS Release | |
---|---|---|
Android API Level | 24 | 16 |
Android Camera Access | Yes | - |
Android Architectures | arm-v7a-neon arm64-v8a x86 x86-64 |
arm-v7a arm-v7a-neon arm64-v8a x86 x86-64 |
Xcode Support | 10.1 | 7.3.1 |
iOS SDK | 12.1 | 9.3 |
iOS Architectures | arm64 arm64e x86-64 |
armv7 arm64 i386 x86-64 |
Packages List
The following FFmpeg Packages List is in reference to the flutter_ffmpeg package.
Package | Main Release | LTS Release |
---|---|---|
min | min | min-lts |
min-gpl | min-gpl | min-gpl-lts |
https | https | https-lts |
https-gpl | https-gpl | https-gpl-lts |
audio | audio | audio-lts |
video | video | video-lts |
full | full | full-lts |
full-gpl | full-gpl | full-gpl-lts |
Functionalities
Loading input video file
Saving trimmed video
Returns a string to indicate whether the saving operation was successful.
Video playback state
Returns the video playback state. If true then the video is playing, otherwise it is paused.
Advanced Command
You can use an advanced FFmpeg command if you require more customization. Just define your FFmpeg command using the ffmpegCommand
property and set an output video format using customVideoFormat
.
Refer to the Official FFmpeg Documentation for more information.
NOTE: Passing a wrong video format to the
customVideoFormat
property may result in a crash.