Skip to content

Commit

Permalink
[feat]use ffmpeg kit config
Browse files Browse the repository at this point in the history
[feat]edit readme
  • Loading branch information
陈军 authored and 陈军 committed Nov 14, 2021
1 parent 68556e3 commit 38000b3
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 156 deletions.
126 changes: 15 additions & 111 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,123 +22,27 @@

<br><br>

## **Installation** (More info on [Flutter FFMPEG](https://pub.dev/packages/flutter_ffmpeg))
## **Installation** (More info on [Flutter ffmepeg kit](https://github.com/tanersener/ffmpeg-kit/tree/main/flutter/flutter))
Following steps will help you add this library as a dependency in your flutter project.

### **Android**
- In the `pubspec.yaml` file in the root of your project

Add on `android/build.gradle` file and define package name in `ext.flutterFFmpegPackage` variable.
```yaml
dependencies:
video_editor: ^1.2.2
```
- Run the following command to get packages:
```gradle
ext.flutterFFmpegPackage = "min-gpl-lts"
```bash
$ flutter packages get
```

### **iOS**

### (Flutter >= 2.x)

- Edit `ios/Podfile`, add the following block **before** `target 'Runner do` and specify the package name in `min-gpl-lts` section:

```python
# "fork" of method flutter_install_plugin_pods (in fluttertools podhelpers.rb) to get lts version of ffmpeg
def flutter_install_plugin_pods(application_path = nil, relative_symlink_dir, platform)
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
raise 'Could not find application path' unless 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(relative_symlink_dir, 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(application_path, '..', '.flutter-plugins-dependencies')
plugin_pods = flutter_parse_plugins_file(plugins_file, platform)
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/min-gpl-lts', :path => File.join(relative_symlink_dir, 'plugins', plugin_name, platform)
else
pod plugin_name, :path => File.join(relative_symlink_dir, 'plugins', plugin_name, platform)
end
end
end
end
```

### (Flutter >= 1.20.x) && (Flutter < 2.x)

- Edit `ios/Podfile`, add the following block **before** `target 'Runner do` and specify the package name in `min-gpl-lts` section:

```python
# "fork" of method flutter_install_ios_plugin_pods (in fluttertools podhelpers.rb) to get lts version of ffmpeg
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 plugin_name + '/min-gpl-lts', :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
else
pod plugin_name, :path => File.join('.symlinks', 'plugins', plugin_name, 'ios')
end
end
end
end
```

- Ensure that `flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))` function is called within
`target 'Runner' do` block. In that case, it is mandatory that the added function is named
`flutter_install_ios_plugin_pods` and that you **do not** make an explicit call within that block.

### (Flutter < 1.20.x)

- Edit `ios/Podfile` file and modify the default `# Plugin Pods` block as follows. Do not forget to specify the package
name in `min-gpl-lts` section.

```python
# 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+'/min-gpl-lts', :path => File.join(symlink, 'ios')
else
pod name, :path => File.join(symlink, 'ios')
end
end
```
- Import the package in your project file:

```dart
import 'package:video_editor/video_editor.dart';
```
<br><br>

## **Example** (The UI Design is fully customizable on the [example](https://pub.dev/packages/video_editor/example))
Expand Down
3 changes: 0 additions & 3 deletions example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,3 @@ subprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}

ext.flutterFFmpegPackage = "min-gpl-lts"

33 changes: 0 additions & 33 deletions example/ios/Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -27,39 +27,6 @@ require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelpe

flutter_ios_podfile_setup

# "fork" of method flutter_install_plugin_pods (in fluttertools podhelpers.rb) to get lts version of ffmpeg
def flutter_install_plugin_pods(application_path = nil, relative_symlink_dir, platform)
# defined_in_file is set by CocoaPods and is a Pathname to the Podfile.
application_path ||= File.dirname(defined_in_file.realpath) if self.respond_to?(:defined_in_file)
raise 'Could not find application path' unless 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(relative_symlink_dir, 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(application_path, '..', '.flutter-plugins-dependencies')
plugin_pods = flutter_parse_plugins_file(plugins_file, platform)
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/min-gpl-lts', :path => File.join(relative_symlink_dir, 'plugins', plugin_name, platform)
else
pod plugin_name, :path => File.join(relative_symlink_dir, 'plugins', plugin_name, platform)
end
end
end
end

target 'Runner' do
flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__))
end
Expand Down
6 changes: 3 additions & 3 deletions example/pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
ffmpeg_kit_flutter:
ffmpeg_kit_flutter_min_gpl:
dependency: transitive
description:
name: ffmpeg_kit_flutter
name: ffmpeg_kit_flutter_min_gpl
url: "https://pub.dartlang.org"
source: hosted
version: "4.5.0"
version: "4.5.0-LTS"
ffmpeg_kit_flutter_platform_interface:
dependency: transitive
description:
Expand Down
4 changes: 2 additions & 2 deletions lib/domain/bloc/controller.dart
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import 'dart:io';
import 'dart:typed_data';
import 'package:ffmpeg_kit_flutter/statistics.dart';
import 'package:ffmpeg_kit_flutter_min_gpl/ffmpeg_kit.dart';
import 'package:ffmpeg_kit_flutter_min_gpl/statistics.dart';
import 'package:path/path.dart' as path;
import 'package:flutter/material.dart';
import 'package:video_player/video_player.dart';
import 'package:path_provider/path_provider.dart';
import 'package:ffmpeg_kit_flutter/ffmpeg_kit.dart';

import 'package:video_editor/domain/entities/crop_style.dart';
import 'package:video_editor/domain/entities/trim_style.dart';
Expand Down
6 changes: 3 additions & 3 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -64,13 +64,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.0.0"
ffmpeg_kit_flutter:
ffmpeg_kit_flutter_min_gpl:
dependency: "direct main"
description:
name: ffmpeg_kit_flutter
name: ffmpeg_kit_flutter_min_gpl
url: "https://pub.dartlang.org"
source: hosted
version: "4.5.0"
version: "4.5.0-LTS"
ffmpeg_kit_flutter_platform_interface:
dependency: transitive
description:
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ environment:
flutter: ">=1.17.0"

dependencies:
ffmpeg_kit_flutter: ^4.5.0-LTS
ffmpeg_kit_flutter_min_gpl: 4.5.0-LTS
flutter:
sdk: flutter
path: ^1.8.0
Expand Down

0 comments on commit 38000b3

Please sign in to comment.