react-native-video-trim 1.0.14 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ npx pod-install ios
|
|
|
22
22
|
```
|
|
23
23
|
|
|
24
24
|
## Usage
|
|
25
|
-
|
|
25
|
+
**Note that for both Android and iOS you have to try on real device**
|
|
26
26
|
|
|
27
27
|
```js
|
|
28
28
|
import { showEditor } from 'react-native-video-trim';
|
|
@@ -228,16 +228,33 @@ useEffect(() => {
|
|
|
228
228
|
# FFMPEG Version
|
|
229
229
|
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
|
|
230
230
|
|
|
231
|
+
## Android
|
|
231
232
|
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`:
|
|
232
233
|
|
|
233
234
|
```gradle
|
|
234
235
|
buildscript {
|
|
235
236
|
ext {
|
|
236
|
-
ffmpegKitPackage = "full" // default "min"
|
|
237
|
+
ffmpegKitPackage = "full" // default "min"
|
|
237
238
|
|
|
238
|
-
ffmpegKitPackageVersion = "5.1.LTS" //
|
|
239
|
+
ffmpegKitPackageVersion = "5.1.LTS" // default 6.0-2
|
|
239
240
|
}
|
|
240
241
|
```
|
|
242
|
+
|
|
243
|
+
## iOS
|
|
244
|
+
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`.
|
|
245
|
+
|
|
246
|
+
You need to pass the variables when running pod install. Eg:
|
|
247
|
+
```shell
|
|
248
|
+
# override package name, default: min
|
|
249
|
+
FFMPEGKIT_PACKAGE=full npx pod-install ios
|
|
250
|
+
|
|
251
|
+
# override package version, default: '~> 6.0
|
|
252
|
+
FFMPEGKIT_PACKAGE_VERSION=5.1 npx pod-install ios
|
|
253
|
+
|
|
254
|
+
# or both
|
|
255
|
+
FFMPEGKIT_PACKAGE=full FFMPEGKIT_PACKAGE_VERSION=5.1 npx pod-install ios
|
|
256
|
+
```
|
|
257
|
+
|
|
241
258
|
# Thanks
|
|
242
259
|
- Android part is created by modified + fix bugs from: https://github.com/iknow4/Android-Video-Trimmer
|
|
243
260
|
- iOS UI is created from: https://github.com/AndreasVerhoeven/VideoTrimmerControl
|
package/android/build.gradle
CHANGED
|
@@ -43,16 +43,14 @@ def supportsNamespace() {
|
|
|
43
43
|
return major >= 8
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
def safePackageName() {
|
|
47
|
+
def name = project.properties['ffmpegKit.android.package.name']
|
|
48
|
+
name + '-' + safeExtGet('ffmpegKitPackage', 'min')
|
|
48
49
|
}
|
|
49
50
|
|
|
50
|
-
def safePackageVersion(
|
|
51
|
-
def
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
// try to get ffmpegKitPackageVersion if possible
|
|
55
|
-
safeExtGet("ffmpegKitPackageVersion", packageName.contains("-lts") ? ltsVersion + ".LTS" : version)
|
|
51
|
+
def safePackageVersion() {
|
|
52
|
+
def name = project.properties['ffmpegKit.android.package.version']
|
|
53
|
+
safeExtGet('ffmpegKitPackageVersion', name)
|
|
56
54
|
}
|
|
57
55
|
|
|
58
56
|
def safeExtGet(String prop, String fallback) {
|
|
@@ -106,7 +104,7 @@ dependencies {
|
|
|
106
104
|
//noinspection GradleDynamicVersion
|
|
107
105
|
implementation "com.facebook.react:react-native:+"
|
|
108
106
|
implementation 'androidx.recyclerview:recyclerview:1.3.1'
|
|
109
|
-
implementation
|
|
107
|
+
implementation safePackageName() + ':' + safePackageVersion()
|
|
110
108
|
}
|
|
111
109
|
|
|
112
110
|
if (isNewArchitectureEnabled()) {
|
|
@@ -3,5 +3,5 @@ VideoTrim_minSdkVersion=21
|
|
|
3
3
|
VideoTrim_targetSdkVersion=31
|
|
4
4
|
VideoTrim_compileSdkVersion=31
|
|
5
5
|
VideoTrim_ndkversion=21.4.7075529
|
|
6
|
-
ffmpegKit.android.
|
|
7
|
-
ffmpegKit.android.
|
|
6
|
+
ffmpegKit.android.package.name=com.arthenica:ffmpeg-kit
|
|
7
|
+
ffmpegKit.android.package.version=6.0-2
|
|
@@ -31,7 +31,7 @@ public class VideoTrimmerUtil {
|
|
|
31
31
|
private static final int THUMB_RESOLUTION_RES = 2; // double thumb resolution for better quality
|
|
32
32
|
|
|
33
33
|
public static void trim(String inputFile, String outputFile, int videoDuration, long startMs, long endMs, final VideoTrimListener callback) {
|
|
34
|
-
String cmd = "-
|
|
34
|
+
String cmd = "-ss " + startMs + "ms" + " -to " + endMs + "ms -i " + inputFile + " -c copy " + outputFile;
|
|
35
35
|
callback.onStartTrim();
|
|
36
36
|
FFmpegKit.executeAsync(cmd, session -> {
|
|
37
37
|
SessionState state = session.getState();
|
package/ios/VideoTrim.swift
CHANGED
|
@@ -279,7 +279,7 @@ class VideoTrim: RCTEventEmitter {
|
|
|
279
279
|
let timestamp = Int(Date().timeIntervalSince1970)
|
|
280
280
|
let outputName = "\(FILE_PREFIX)_\(timestamp).mp4" // use mp4 to prevent any issue with ffmpeg about file extension
|
|
281
281
|
let outputFile = "\(inputFile.deletingLastPathComponent().absoluteURL)\(outputName)"
|
|
282
|
-
let cmd = "-
|
|
282
|
+
let cmd = "-ss \(startTime * 1000)ms -to \(endTime * 1000)ms -i \(inputFile) -c copy \(outputFile)";
|
|
283
283
|
|
|
284
284
|
self.emitEventToJS("onStartTrimming", eventData: nil)
|
|
285
285
|
|
package/package.json
CHANGED
|
@@ -15,7 +15,7 @@ Pod::Spec.new do |s|
|
|
|
15
15
|
s.source = { :git => "https://github.com/maitrungduc1410/react-native-video-trim.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
|
-
s.dependency
|
|
18
|
+
s.dependency "ffmpeg-kit-ios-#{ENV['FFMPEGKIT_PACKAGE'] || 'min'}", ENV['FFMPEGKIT_PACKAGE_VERSION'] || '~> 6.0'
|
|
19
19
|
|
|
20
20
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
21
21
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|