Skip to content

Commit

Permalink
feat: support dynamic pod version for ios
Browse files Browse the repository at this point in the history
  • Loading branch information
maitrungduc1410 committed Feb 20, 2024
1 parent c1c7183 commit 4b1a566
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 19 deletions.
21 changes: 19 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,33 @@ useEffect(() => {
# FFMPEG Version
This library uses FFMPEG-Kit Android under the hood, by default FFMPEG-min is used, which gives smallest bundle size: https://github.com/arthenica/ffmpeg-kit#9-packages

## Android
If you ever need to use other version of FFMPEG-Kit for Android, you can do the following, in your `android/build.gradle` > `buildscript` > `ext`:

```gradle
buildscript {
ext {
ffmpegKitPackage = "full" // default "min", if followed by lts then LTS version is use. Eg "full-lts"
ffmpegKitPackage = "full" // default "min"
ffmpegKitPackageVersion = "5.1.LTS" // use exact version, highest precedence, default 6.0-2 if ignored
ffmpegKitPackageVersion = "5.1.LTS" // default 6.0-2
}
```

## iOS
Same as Android, there're 2 environment variables respectively you can use to specify FFMPEG Kit version you want to use: `FFMPEG_KIT_PACKAGE` and `FFMPEG_KIT_PACKAGE_VERSION`.

You need to pass the variables when running pod install. Eg:
```shell
# override package name, default: min
FFMPEGKIT_PACKAGE=full npx pod-install ios

# override package version, default: '~> 6.0
FFMPEGKIT_PACKAGE_VERSION=5.1 npx pod-install ios

# or both
FFMPEGKIT_PACKAGE=full FFMPEGKIT_PACKAGE_VERSION=5.1 npx pod-install ios
```

# Thanks
- Android part is created by modified + fix bugs from: https://github.com/iknow4/Android-Video-Trimmer
- iOS UI is created from: https://github.com/AndreasVerhoeven/VideoTrimmerControl
16 changes: 7 additions & 9 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,14 @@ def supportsNamespace() {
return major >= 8
}

static def safePackageName(String packageName) {
packageName.replace("-lts", "")
def safePackageName() {
def name = project.properties['ffmpegKit.android.package.name']
name + '-' + safeExtGet('ffmpegKitPackage', 'min')
}

def safePackageVersion(String packageName) {
def version = project.properties['ffmpegKit.android.main.version']
def ltsVersion = project.properties['ffmpegKit.android.lts.version']

// try to get ffmpegKitPackageVersion if possible
safeExtGet("ffmpegKitPackageVersion", packageName.contains("-lts") ? ltsVersion + ".LTS" : version)
def safePackageVersion() {
def name = project.properties['ffmpegKit.android.package.version']
safeExtGet('ffmpegKitPackageVersion', name)
}

def safeExtGet(String prop, String fallback) {
Expand Down Expand Up @@ -106,7 +104,7 @@ dependencies {
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+"
implementation 'androidx.recyclerview:recyclerview:1.3.1'
implementation 'com.arthenica:ffmpeg-kit-' + safePackageName(safeExtGet('ffmpegKitPackage', 'min')) + ':' + safePackageVersion(safeExtGet('ffmpegKitPackage', 'min'))
implementation safePackageName() + ':' + safePackageVersion()
}

if (isNewArchitectureEnabled()) {
Expand Down
4 changes: 2 additions & 2 deletions android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ VideoTrim_minSdkVersion=21
VideoTrim_targetSdkVersion=31
VideoTrim_compileSdkVersion=31
VideoTrim_ndkversion=21.4.7075529
ffmpegKit.android.main.version=6.0-2
ffmpegKit.android.lts.version=6.0-2
ffmpegKit.android.package.name=com.arthenica:ffmpeg-kit
ffmpegKit.android.package.version=6.0-2
2 changes: 1 addition & 1 deletion example/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ buildscript {
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"

// ffmpegKitPackage = "min"
// ffmpegKitPackage = "full"
// ffmpegKitPackageVersion = "5.1.LTS"
}
repositories {
Expand Down
6 changes: 3 additions & 3 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ PODS:
- glog
- react-native-image-picker (5.6.0):
- React-Core
- react-native-video-trim (1.0.10):
- react-native-video-trim (1.0.14):
- ffmpeg-kit-ios-min (~> 6.0)
- RCT-Folly (= 2021.07.22.00)
- React-Core
Expand Down Expand Up @@ -703,7 +703,7 @@ SPEC CHECKSUMS:
React-jsinspector: b511447170f561157547bc0bef3f169663860be7
React-logger: c5b527272d5f22eaa09bb3c3a690fee8f237ae95
react-native-image-picker: db60857e03d63721f19b6f4027de20429ddd9cba
react-native-video-trim: 78275e522da1a38174864c61e35cb99219e9d158
react-native-video-trim: fb7e3ff499f053a14776ffa454785db4dcdcc366
React-NativeModulesApple: c57f3efe0df288a6532b726ad2d0322a9bf38472
React-perflogger: 6bd153e776e6beed54c56b0847e1220a3ff92ba5
React-RCTActionSheet: c0b62af44e610e69d9a2049a682f5dba4e9dff17
Expand All @@ -727,4 +727,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ecd8179b4688b156375776f99c2ce179b78bc497

COCOAPODS: 1.12.1
COCOAPODS: 1.14.3
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-video-trim",
"version": "1.0.14",
"version": "1.0.15",
"description": "Video trimmer for your React Native app",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion react-native-video-trim.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
s.source = { :git => "https://github.com/maitrungduc1410/react-native-video-trim.git", :tag => "#{s.version}" }

s.source_files = "ios/**/*.{h,m,mm,swift}"
s.dependency 'ffmpeg-kit-ios-min', '~> 6.0'
s.dependency "ffmpeg-kit-ios-#{ENV['FFMPEGKIT_PACKAGE'] || 'min'}", ENV['FFMPEGKIT_PACKAGE_VERSION'] || '~> 6.0'

# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
Expand Down

0 comments on commit 4b1a566

Please sign in to comment.