react-native-video-processing 1.7.1 → 1.7.2

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.
Files changed (56) hide show
  1. package/.travis.yml +1 -1
  2. package/CODE_OF_CONDUCT.md +46 -0
  3. package/ISSUE_TEMPLATE.md +21 -0
  4. package/README.md +94 -39
  5. package/_config.yml +1 -0
  6. package/android/build.gradle +26 -10
  7. package/android/src/main/java/com/shahenlibrary/Events/Events.java +2 -0
  8. package/android/src/main/java/com/shahenlibrary/RNVideoProcessingPackage.java +1 -2
  9. package/android/src/main/java/com/shahenlibrary/Trimmer/Trimmer.java +705 -112
  10. package/android/src/main/java/com/shahenlibrary/Trimmer/TrimmerManager.java +50 -7
  11. package/android/src/main/java/com/shahenlibrary/VideoPlayer/VideoPlayerView.java +63 -5
  12. package/android/src/main/java/com/shahenlibrary/VideoPlayer/VideoPlayerViewManager.java +17 -12
  13. package/android/src/main/java/com/shahenlibrary/interfaces/OnCompressVideoListener.java +8 -0
  14. package/android/src/main/java/com/shahenlibrary/utils/VideoEdit.java +34 -7
  15. package/android/src/main/jniLibs/arm64-v8a/libffmpeg.so +0 -0
  16. package/android/src/main/jniLibs/armeabi-v7a/libffmpeg.so +0 -0
  17. package/android/src/main/jniLibs/x86/libffmpeg.so +0 -0
  18. package/android/src/main/jniLibs/x86_64/libffmpeg.so +0 -0
  19. package/ios/RNVideoProcessing/RCTSwiftBridgeModule.h +29 -0
  20. package/ios/RNVideoProcessing/RNTrimmerView/ICGVideoTrimmer/ICGVideoTrimmerView.h +5 -0
  21. package/ios/RNVideoProcessing/RNTrimmerView/ICGVideoTrimmer/ICGVideoTrimmerView.m +48 -13
  22. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerView.h +1 -0
  23. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerView.swift +107 -36
  24. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerViewBridge.m +4 -1
  25. package/ios/RNVideoProcessing/RNTrimmerView/RNTrimmerViewManager.swift +4 -1
  26. package/ios/RNVideoProcessing/RNVideoPlayer.swift +89 -45
  27. package/ios/RNVideoProcessing/RNVideoProcessingBridge.m +3 -1
  28. package/ios/RNVideoProcessing/RNVideoProcessingManager.swift +16 -10
  29. package/ios/RNVideoProcessing/RNVideoTrimmer/AVUtilities.swift +81 -0
  30. package/ios/RNVideoProcessing/RNVideoTrimmer/RNVideoTrimmer.swift +630 -207
  31. package/ios/RNVideoProcessing/RNVideoTrimmer/RNVideoTrimmerBridge.m +8 -3
  32. package/ios/RNVideoProcessing/RNVideoTrimmer/SDAVAssetExportSession.m +32 -32
  33. package/ios/RNVideoProcessing/VideoProcessingGPUFilters.swift +0 -1
  34. package/ios/RNVideoProcessing.xcodeproj/project.pbxproj +10 -3
  35. package/lib/ProcessingManager/ProcessingManager.android.js +81 -17
  36. package/lib/ProcessingManager/ProcessingManager.ios.js +72 -10
  37. package/lib/ProcessingManager/index.js +1 -1
  38. package/lib/ProcessingManager/test/ProcessingManager.test.js +24 -0
  39. package/lib/ProcessingManager/types.android.js +26 -0
  40. package/lib/ProcessingManager/types.ios.js +21 -3
  41. package/lib/Trimmer/Trimmer.android.js +4 -6
  42. package/lib/Trimmer/Trimmer.ios.js +15 -3
  43. package/lib/Trimmer/test/Trimmer.test.js +6 -3
  44. package/lib/Trimmer/test/__snapshots__/Trimmer.test.js.snap +4 -1
  45. package/lib/VideoPlayer/VideoPlayer.android.js +52 -6
  46. package/lib/VideoPlayer/VideoPlayer.ios.js +13 -10
  47. package/lib/VideoPlayer/test/__snapshots__/VideoPlayer.test.js.snap +4 -1
  48. package/lib/utils/index.js +1 -1
  49. package/lib/utils/test/trimmer.test.js +55 -0
  50. package/lib/utils/test/utils.test.js +1 -1
  51. package/lib/utils/trimmer.js +12 -0
  52. package/package.json +37 -26
  53. package/.npmignore +0 -60
  54. package/init/index.js +0 -7
  55. package/ios/GPUImage/.npmignore +0 -25
  56. package/yarn.lock +0 -6183
package/.travis.yml CHANGED
@@ -4,7 +4,7 @@ cache:
4
4
  directories:
5
5
  - node_modules
6
6
  node_js:
7
- - '6'
7
+ - '8'
8
8
  before_script:
9
9
  - npm prune
10
10
  script:
@@ -0,0 +1,46 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ ## Our Standards
8
+
9
+ Examples of behavior that contributes to creating a positive environment include:
10
+
11
+ * Using welcoming and inclusive language
12
+ * Being respectful of differing viewpoints and experiences
13
+ * Gracefully accepting constructive criticism
14
+ * Focusing on what is best for the community
15
+ * Showing empathy towards other community members
16
+
17
+ Examples of unacceptable behavior by participants include:
18
+
19
+ * The use of sexualized language or imagery and unwelcome sexual attention or advances
20
+ * Trolling, insulting/derogatory comments, and personal or political attacks
21
+ * Public or private harassment
22
+ * Publishing others' private information, such as a physical or electronic address, without explicit permission
23
+ * Other conduct which could reasonably be considered inappropriate in a professional setting
24
+
25
+ ## Our Responsibilities
26
+
27
+ Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.
28
+
29
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.
30
+
31
+ ## Scope
32
+
33
+ This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.
34
+
35
+ ## Enforcement
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at shahen.hovhannisyan.94@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.
38
+
39
+ Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.
40
+
41
+ ## Attribution
42
+
43
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version]
44
+
45
+ [homepage]: http://contributor-covenant.org
46
+ [version]: http://contributor-covenant.org/version/1/4/
@@ -0,0 +1,21 @@
1
+ <!---
2
+ BEFORE YOU SUBMIT please search open/closed issues since someone might have asked the same thing before!
3
+ -->
4
+
5
+ ### Current Behavior
6
+ <!--- If describing a bug, tell us what happens instead of the expected behavior -->
7
+ <!--- If suggesting a change/improvement, explain the difference from current behavior -->
8
+
9
+ ### Expected Behavior
10
+ <!--- If you're describing a bug, tell us what should happen -->
11
+ <!--- If you're suggesting a change/improvement, tell us how it should work -->
12
+
13
+
14
+ ### Your Environment
15
+ <!--- Include as many relevant details about the environment you experienced the bug in -->
16
+
17
+ | software | version
18
+ | ------------------------------ | -------
19
+ | react-native-video-processing |
20
+ | react-native |
21
+ | node |
package/README.md CHANGED
@@ -6,41 +6,86 @@
6
6
  ```sh
7
7
  npm install react-native-video-processing --save
8
8
  ```
9
- ### You can check test just running
9
+ ```sh
10
+ yarn add react-native-video-processing
11
+ ```
12
+ ### You can check test by running
10
13
  `$ npm test` or `$ yarn test`
11
14
 
12
- ### Manual installation
15
+ ### Installation
16
+ **Note: For RN 0.4x use 1.0 version, for RN 0.3x use 0.16**
13
17
 
14
- **Note: For RN 0.4x use 1.0 version, For RN 0.3x use  0.16**
15
18
  #### [Android]
16
- ```sh
17
- $ react-native link react-native-video-processing
19
+ - Open up `android/app/src/main/java/[...]/MainApplication.java`
20
+
21
+ - Add `import com.shahenlibrary.RNVideoProcessingPackage;` to the imports at the top of the file
22
+
23
+ - Add new `new RNVideoProcessingPackage()` to the list returned by the getPackages() method
24
+
25
+ - Append the following lines to `android/settings.gradle`:
18
26
  ```
27
+ include ':react-native-video-processing'
28
+ project(':react-native-video-processing').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video-processing/android')
29
+ ```
30
+
31
+ - Insert the following lines inside the dependencies block in `android/app/build.gradle`:
32
+ ```
33
+ compile project(':react-native-video-processing')
34
+ ```
35
+
36
+ - Add the following lines to `AndroidManifest.xml`:
37
+ ```
38
+ <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
39
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
40
+ ```
41
+
19
42
  #### [iOS]
20
43
 
21
- 1. In Xcode, click the "Add Files to <your-project-name>".
22
- 2. Go to `node_modules` ➜ `react-native-video-processing/ios` and add `RNVideoProcessing` directory.
23
- 3. Make sure `RNVideoProcessing` is "under" the "top-level".
24
- 4. Add `GPUImage.xcodeproj` from `node_modules/react-native-video-processing/ios/GPUImage/framework` directory to your project and make sure it is "under" the "top-level":
44
+ 1. In Xcode, right click your Xcode project and create `New Group` called `RNVideoProcessing`.
45
+
46
+ 2. Go to `node_modules/react-native-video-processing/ios/RNVideoProcessing` and drag the `.swift` files under the group you just created. Press `Create folder references` option if not pressed.
25
47
 
26
- ![Project Structure](readme_assets/project-structure.png)
48
+ 3. Repeat steps 1 & 2 for the subdirectories `RNVideoTrimmer`, `RNTrimmerView`, and `ICGVideoTrimmer` and all the files underneath them. Make sure you keep the folders hierarchy the same.
27
49
 
28
- 5. In XCode, in the project navigator, select your project.
50
+ 4. Go to `node_modules/react-native-video-processing/ios/GPUImage/framework` and drag `GPUImage.xcodeproj` to your project's root directory in Xcode.
29
51
 
30
- Add
31
- - CoreMedia
32
- - CoreVideo
33
- - OpenGLES
34
- - AVFoundation
35
- - QuartzCore
36
- - GPUImage
37
- - MobileCoreServices
52
+ ![Project Structure](readme_assets/project-structure.png)
38
53
 
39
- to your project's `Build Phases` ➜ `Link Binary With Libraries`.
40
- 6. Import `RNVideoProcessing.h` into your `project_name-bridging-header.h`.
41
- 7. Clean and Run your project.
54
+ 5. Under your project's `Build Phases`, make sure the `.swift` files you added appear under `Compile Sources`.
55
+
56
+ 6. Under your project's `General` tab, add the following frameworks to `Linked Frameworks and Libraries` :
57
+
58
+ - CoreMedia
59
+ - CoreVideo
60
+ - OpenGLES
61
+ - AVFoundation
62
+ - QuartzCore
63
+ - MobileCoreServices
64
+ - GPUImage
65
+
66
+ 7. Add `GPUImage.frameworkiOS` to `Embedded Binaries`.
67
+
68
+ 8. Navigate to your project's bridging header file *<ProjectName-Bridging-Header.h>* and add `#import "RNVideoProcessing.h"`.
69
+
70
+ 9. Clean and run your project.
71
+
72
+ *Check the following video for more setup reference.*
73
+
74
+ [![Setup](https://img.youtube.com/vi/HRjgeT6NQJM/0.jpg)](https://youtu.be/HRjgeT6NQJM)
75
+
76
+ ## Update ffmpeg binaries
77
+ 1. Clone [mobile-ffmpeg](https://github.com/tanersener/mobile-ffmpeg)
78
+ 2. Setup project, see [Prerequisites](https://github.com/tanersener/mobile-ffmpeg#51-prerequisites) in README.
79
+ 3. Modify `build/android-ffmpeg.sh` so it generates binaries ([more info](https://github.com/tanersener/mobile-ffmpeg/issues/30#issuecomment-425964213))
80
+ 1. Delete --disable-programs line
81
+ 2. Change --disable-static line to --enable-static
82
+ 3. Delete --enable-shared line
83
+ 4. Compile binaries: `./android.sh --lts --disable-arm-v7a-neon --enable-x264 --enable-gpl --speed`. The command might finish with `failed`. That's okay because we modified the build script. Make sure every build outputs: `ffmpeg: ok`.
84
+ 5. Find `ffmpeg` binaries in `prebuilt/[android-arm|android-arm64|android-x86|android-x86_64]/ffmpeg/bin/ffmpeg`
85
+ 6. Copy and rename binaries to `android/src/main/jniLibs/[armeabi-v7a|arm64-v8a|x86|x86_64]/libffmpeg.so`. Make sure you rename the binaries from `ffmpeg` to `libffmpeg.so`!
86
+
87
+ ## Example Usage
42
88
 
43
- ## Usage
44
89
  ```javascript
45
90
  import React, { Component } from 'react';
46
91
  import { View } from 'react-native';
@@ -60,15 +105,15 @@ class App extends Component {
60
105
  .catch(console.warn);
61
106
  }
62
107
 
63
- // iOS only
64
108
  compressVideo() {
65
109
  const options = {
66
110
  width: 720,
67
- endTime: 1280,
111
+ height: 1280,
68
112
  bitrateMultiplier: 3,
69
- saveToCameraRoll: true, // default is false
70
- saveWithCurrentDate: true, // default is false
71
- minimumBitrate: 300000
113
+ saveToCameraRoll: true, // default is false, iOS only
114
+ saveWithCurrentDate: true, // default is false, iOS only
115
+ minimumBitrate: 300000,
116
+ removeAudio: true, // default is false
72
117
  };
73
118
  this.videoPlayerRef.compress(options)
74
119
  .then((newSource) => console.log(newSource))
@@ -121,23 +166,30 @@ class App extends Component {
121
166
  }
122
167
  }
123
168
  ```
124
- or you can use ProcessingManager without mounting VideoPlayer component
169
+ Or you can use `ProcessingManager` without mounting `VideoPlayer` component:
125
170
  ```javascript
126
171
  import React, { Component } from 'react';
127
- import { View } from 'react-native';
172
+ import { View } from 'react-native';
128
173
  import { ProcessingManager } from 'react-native-video-processing';
129
174
  export class App extends Component {
130
175
  componentWillMount() {
131
- const { source } = this.props;
176
+ const { source } = this.props;
132
177
  ProcessingManager.getVideoInfo(source)
133
- .then(({ duration, size }) => console.log(duration, size));
134
-
178
+ .then(({ duration, size, frameRate, bitrate }) => console.log(duration, size, frameRate, bitrate));
179
+
180
+ // on iOS it's possible to trim remote files by using remote file as source
135
181
  ProcessingManager.trim(source, options) // like VideoPlayer trim options
136
182
  .then((data) => console.log(data));
137
-
183
+
138
184
  ProcessingManager.compress(source, options) // like VideoPlayer compress options
139
185
  .then((data) => console.log(data));
140
-
186
+
187
+ ProcessingManager.reverse(source) // reverses the source video
188
+ .then((data) => console.log(data)); // returns the new file source
189
+
190
+ ProcessingManager.boomerang(source) // creates a "boomerang" of the surce video (plays forward then plays backwards)
191
+ .then((data) => console.log(data)); // returns the new file source
192
+
141
193
  const maximumSize = { width: 100, height: 200 };
142
194
  ProcessingManager.getPreviewForSecond(source, forSecond, maximumSize)
143
195
  .then((data) => console.log(data))
@@ -148,8 +200,10 @@ export class App extends Component {
148
200
  }
149
201
  ```
150
202
 
151
- ### How to setup Library
152
- [![Setup](https://img.youtube.com/vi/HRjgeT6NQJM/0.jpg)](https://youtu.be/HRjgeT6NQJM)
203
+ ##
204
+ If this project was helpful to you, please <html>
205
+ <a href="https://www.buymeacoffee.com/FnENSxi" target="_blank"><img src="https://bmc-cdn.nyc3.digitaloceanspaces.com/BMC-button-images/custom_images/yellow_img.png" alt="Buy Me A Coffee" style="height: auto !important;width: auto;" ></a>
206
+ </html>
153
207
 
154
208
  ## Contributing
155
209
 
@@ -159,7 +213,8 @@ export class App extends Component {
159
213
  ## Roadmap
160
214
  1. [ ] Use FFMpeg instead of MP4Parser
161
215
  2. [ ] Add ability to add GLSL filters
162
- 3. [ ] Android should be able to compress video
163
- 4. [ ] More processing options
216
+ 3. [x] Android should be able to compress video
217
+ 4. [x] More processing options
164
218
  5. [ ] Create native trimmer component for Android
165
219
  6. [x] Provide Standalone API
220
+ 7. [ ] Describe API methods with parameters in README
package/_config.yml ADDED
@@ -0,0 +1 @@
1
+ theme: jekyll-theme-cayman
@@ -1,17 +1,20 @@
1
-
2
1
  apply plugin: 'com.android.library'
3
2
 
3
+ def safeExtGet(prop, fallback) {
4
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
+ }
6
+
4
7
  android {
5
- compileSdkVersion 23
6
- buildToolsVersion "23.0.1"
8
+ compileSdkVersion safeExtGet('compileSdkVersion', 29)
9
+ buildToolsVersion safeExtGet('buildToolsVersion', "29.0.3")
7
10
 
8
11
  defaultConfig {
9
- minSdkVersion 16
10
- targetSdkVersion 22
12
+ minSdkVersion safeExtGet('minSdkVersion', 16)
13
+ targetSdkVersion safeExtGet('targetSdkVersion', 29)
11
14
  versionCode 1
12
15
  versionName "1.0"
13
16
  ndk {
14
- abiFilters "armeabi-v7a", "x86"
17
+ abiFilters "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
15
18
  }
16
19
  }
17
20
  lintOptions {
@@ -19,9 +22,22 @@ android {
19
22
  }
20
23
  }
21
24
 
25
+ configurations.all {
26
+ resolutionStrategy.cacheChangingModulesFor 0, 'seconds'
27
+ }
28
+
29
+
22
30
  dependencies {
23
- compile 'com.facebook.react:react-native:0.20.+'
24
- compile 'com.yqritc:android-scalablevideoview:1.0.4'
25
- compile 'com.googlecode.mp4parser:isoparser:1.1.20'
26
- compile 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
31
+ implementation 'com.facebook.react:react-native:+'
32
+ implementation 'com.yqritc:android-scalablevideoview:1.0.4'
33
+ implementation 'com.googlecode.mp4parser:isoparser:1.1.20'
34
+ implementation 'com.github.wseemann:FFmpegMediaMetadataRetriever:1.0.14'
35
+ // implementation "com.google.android.gms:play-services-gcm:12.+"
36
+ }
37
+
38
+ allprojects {
39
+ repositories {
40
+ mavenLocal()
41
+ jcenter()
42
+ }
27
43
  }
@@ -12,4 +12,6 @@ public class Events {
12
12
  public static final String ERROR_TRIM = "error";
13
13
  public static final String ORIENTATION = "orientation";
14
14
  public static final String SIZE = "size";
15
+ public static final String FRAMERATE = "frameRate";
16
+ public static final String BITRATE = "bitrate";
15
17
  }
@@ -43,7 +43,6 @@ public class RNVideoProcessingPackage implements ReactPackage {
43
43
  );
44
44
  }
45
45
 
46
- @Override
47
46
  public List<Class<? extends JavaScriptModule>> createJSModules() {
48
47
  return Collections.emptyList();
49
48
  }
@@ -54,4 +53,4 @@ public class RNVideoProcessingPackage implements ReactPackage {
54
53
  new VideoPlayerViewManager()
55
54
  );
56
55
  }
57
- }
56
+ }