munim-ffmpeg 0.1.0

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 (60) hide show
  1. package/LICENSE +178 -0
  2. package/NitroMunimFfmpeg.podspec +41 -0
  3. package/README.md +95 -0
  4. package/android/CMakeLists.txt +29 -0
  5. package/android/build.gradle +144 -0
  6. package/android/fix-prefab.gradle +51 -0
  7. package/android/gradle.properties +5 -0
  8. package/android/src/main/AndroidManifest.xml +2 -0
  9. package/android/src/main/cpp/cpp-adapter.cpp +9 -0
  10. package/android/src/main/java/com/margelo/nitro/munimffmpeg/HybridMunimFfmpeg.kt +141 -0
  11. package/android/src/main/java/com/margelo/nitro/munimffmpeg/NitroMunimFfmpegPackage.kt +18 -0
  12. package/app.plugin.js +5 -0
  13. package/ios/Bridge.h +8 -0
  14. package/ios/HybridMunimFfmpeg.swift +161 -0
  15. package/lib/index.d.ts +10 -0
  16. package/lib/index.js +21 -0
  17. package/lib/specs/MunimFfmpeg.nitro.d.ts +25 -0
  18. package/lib/specs/MunimFfmpeg.nitro.js +1 -0
  19. package/nitro.json +30 -0
  20. package/nitrogen/generated/.gitattributes +1 -0
  21. package/nitrogen/generated/android/NitroMunimFfmpeg+autolinking.cmake +81 -0
  22. package/nitrogen/generated/android/NitroMunimFfmpeg+autolinking.gradle +27 -0
  23. package/nitrogen/generated/android/NitroMunimFfmpegOnLoad.cpp +60 -0
  24. package/nitrogen/generated/android/NitroMunimFfmpegOnLoad.hpp +34 -0
  25. package/nitrogen/generated/android/c++/JFFmpegSessionResult.hpp +86 -0
  26. package/nitrogen/generated/android/c++/JFunc_void_double.hpp +75 -0
  27. package/nitrogen/generated/android/c++/JFunc_void_double_double_double_double_double_double_double.hpp +75 -0
  28. package/nitrogen/generated/android/c++/JFunc_void_std__string.hpp +76 -0
  29. package/nitrogen/generated/android/c++/JHybridMunimFfmpegSpec.cpp +138 -0
  30. package/nitrogen/generated/android/c++/JHybridMunimFfmpegSpec.hpp +67 -0
  31. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/FFmpegSessionResult.kt +86 -0
  32. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/Func_void_double.kt +78 -0
  33. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/Func_void_double_double_double_double_double_double_double.kt +78 -0
  34. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/Func_void_std__string.kt +78 -0
  35. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/HybridMunimFfmpegSpec.kt +85 -0
  36. package/nitrogen/generated/android/kotlin/com/margelo/nitro/munimffmpeg/NitroMunimFfmpegOnLoad.kt +35 -0
  37. package/nitrogen/generated/ios/NitroMunimFfmpeg+autolinking.rb +62 -0
  38. package/nitrogen/generated/ios/NitroMunimFfmpeg-Swift-Cxx-Bridge.cpp +73 -0
  39. package/nitrogen/generated/ios/NitroMunimFfmpeg-Swift-Cxx-Bridge.hpp +298 -0
  40. package/nitrogen/generated/ios/NitroMunimFfmpeg-Swift-Cxx-Umbrella.hpp +51 -0
  41. package/nitrogen/generated/ios/NitroMunimFfmpegAutolinking.mm +33 -0
  42. package/nitrogen/generated/ios/NitroMunimFfmpegAutolinking.swift +26 -0
  43. package/nitrogen/generated/ios/c++/HybridMunimFfmpegSpecSwift.cpp +11 -0
  44. package/nitrogen/generated/ios/c++/HybridMunimFfmpegSpecSwift.hpp +119 -0
  45. package/nitrogen/generated/ios/swift/FFmpegSessionResult.swift +77 -0
  46. package/nitrogen/generated/ios/swift/Func_void_FFmpegSessionResult.swift +46 -0
  47. package/nitrogen/generated/ios/swift/Func_void_double.swift +46 -0
  48. package/nitrogen/generated/ios/swift/Func_void_double_double_double_double_double_double_double.swift +46 -0
  49. package/nitrogen/generated/ios/swift/Func_void_std__exception_ptr.swift +46 -0
  50. package/nitrogen/generated/ios/swift/Func_void_std__string.swift +46 -0
  51. package/nitrogen/generated/ios/swift/HybridMunimFfmpegSpec.swift +59 -0
  52. package/nitrogen/generated/ios/swift/HybridMunimFfmpegSpec_cxx.swift +277 -0
  53. package/nitrogen/generated/shared/c++/FFmpegSessionResult.hpp +112 -0
  54. package/nitrogen/generated/shared/c++/HybridMunimFfmpegSpec.cpp +26 -0
  55. package/nitrogen/generated/shared/c++/HybridMunimFfmpegSpec.hpp +72 -0
  56. package/package.json +131 -0
  57. package/react-native.config.js +16 -0
  58. package/scripts/patch-ffmpegkit-level.rb +45 -0
  59. package/src/index.ts +56 -0
  60. package/src/specs/MunimFfmpeg.nitro.ts +52 -0
package/LICENSE ADDED
@@ -0,0 +1,178 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ https://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction, and
10
+ distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by the
13
+ copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all other
16
+ entities that control, are controlled by, or are under common control with
17
+ that entity. For the purposes of this definition, "control" means (i) the
18
+ power, direct or indirect, to cause the direction or management of such
19
+ entity, whether by contract or otherwise, or (ii) ownership of fifty percent
20
+ (50%) or more of the outstanding shares, or (iii) beneficial ownership of
21
+ such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
24
+ permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation source, and
28
+ configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical transformation
31
+ or translation of a Source form, including but not limited to compiled object
32
+ code, generated documentation, and conversions to other media types.
33
+
34
+ "Work" shall mean the work of authorship, whether in Source or Object form,
35
+ made available under the License, as indicated by a copyright notice that is
36
+ included in or attached to the work (an example is provided in the Appendix
37
+ below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form,
40
+ that is based on (or derived from) the Work and for which the editorial
41
+ revisions, annotations, elaborations, or other modifications represent, as a
42
+ whole, an original work of authorship. For the purposes of this License,
43
+ Derivative Works shall not include works that remain separable from, or merely
44
+ link (or bind by name) to the interfaces of, the Work and Derivative Works
45
+ thereof.
46
+
47
+ "Contribution" shall mean any work of authorship, including the original
48
+ version of the Work and any modifications or additions to that Work or
49
+ Derivative Works thereof, that is intentionally submitted to Licensor for
50
+ inclusion in the Work by the copyright owner or by an individual or Legal
51
+ Entity authorized to submit on behalf of the copyright owner. For the purposes
52
+ of this definition, "submitted" means any form of electronic, verbal, or
53
+ written communication sent to the Licensor or its representatives, including
54
+ but not limited to communication on electronic mailing lists, source code
55
+ control systems, and issue tracking systems that are managed by, or on behalf
56
+ of, the Licensor for the purpose of discussing and improving the Work, but
57
+ excluding communication that is conspicuously marked or otherwise designated
58
+ in writing by the copyright owner as "Not a Contribution."
59
+
60
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
61
+ of whom a Contribution has been received by Licensor and subsequently
62
+ incorporated within the Work.
63
+
64
+ 2. Grant of Copyright License. Subject to the terms and conditions of this
65
+ License, each Contributor hereby grants to You a perpetual, worldwide,
66
+ non-exclusive, no-charge, royalty-free, irrevocable copyright license to
67
+ reproduce, prepare Derivative Works of, publicly display, publicly perform,
68
+ sublicense, and distribute the Work and such Derivative Works in Source or
69
+ Object form.
70
+
71
+ 3. Grant of Patent License. Subject to the terms and conditions of this
72
+ License, each Contributor hereby grants to You a perpetual, worldwide,
73
+ non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this
74
+ section) patent license to make, have made, use, offer to sell, sell, import,
75
+ and otherwise transfer the Work, where such license applies only to those
76
+ patent claims licensable by such Contributor that are necessarily infringed by
77
+ their Contribution(s) alone or by combination of their Contribution(s) with
78
+ the Work to which such Contribution(s) was submitted. If You institute patent
79
+ litigation against any entity (including a cross-claim or counterclaim in a
80
+ lawsuit) alleging that the Work or a Contribution incorporated within the Work
81
+ constitutes direct or contributory patent infringement, then any patent
82
+ licenses granted to You under this License for that Work shall terminate as of
83
+ the date such litigation is filed.
84
+
85
+ 4. Redistribution. You may reproduce and distribute copies of the Work or
86
+ Derivative Works thereof in any medium, with or without modifications, and in
87
+ Source or Object form, provided that You meet the following conditions:
88
+
89
+ (a) You must give any other recipients of the Work or Derivative Works a copy
90
+ of this License; and
91
+
92
+ (b) You must cause any modified files to carry prominent notices stating that
93
+ You changed the files; and
94
+
95
+ (c) You must retain, in the Source form of any Derivative Works that You
96
+ distribute, all copyright, patent, trademark, and attribution notices from the
97
+ Source form of the Work, excluding those notices that do not pertain to any
98
+ part of the Derivative Works; and
99
+
100
+ (d) If the Work includes a "NOTICE" text file as part of its distribution,
101
+ then any Derivative Works that You distribute must include a readable copy of
102
+ the attribution notices contained within such NOTICE file, excluding those
103
+ notices that do not pertain to any part of the Derivative Works, in at least
104
+ one of the following places: within a NOTICE text file distributed as part of
105
+ the Derivative Works; within the Source form or documentation, if provided
106
+ along with the Derivative Works; or, within a display generated by the
107
+ Derivative Works, if and wherever such third-party notices normally appear.
108
+ The contents of the NOTICE file are for informational purposes only and do not
109
+ modify the License. You may add Your own attribution notices within Derivative
110
+ Works that You distribute, alongside or as an addendum to the NOTICE text from
111
+ the Work, provided that such additional attribution notices cannot be
112
+ construed as modifying the License.
113
+
114
+ You may add Your own copyright statement to Your modifications and may provide
115
+ additional or different license terms and conditions for use, reproduction, or
116
+ distribution of Your modifications, or for any such Derivative Works as a
117
+ whole, provided Your use, reproduction, and distribution of the Work otherwise
118
+ complies with the conditions stated in this License.
119
+
120
+ 5. Submission of Contributions. Unless You explicitly state otherwise, any
121
+ Contribution intentionally submitted for inclusion in the Work by You to the
122
+ Licensor shall be under the terms and conditions of this License, without any
123
+ additional terms or conditions. Notwithstanding the above, nothing herein
124
+ shall supersede or modify the terms of any separate license agreement you may
125
+ have executed with Licensor regarding such Contributions.
126
+
127
+ 6. Trademarks. This License does not grant permission to use the trade names,
128
+ trademarks, service marks, or product names of the Licensor, except as required
129
+ for reasonable and customary use in describing the origin of the Work and
130
+ reproducing the content of the NOTICE file.
131
+
132
+ 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in
133
+ writing, Licensor provides the Work (and each Contributor provides its
134
+ Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
135
+ KIND, either express or implied, including, without limitation, any warranties
136
+ or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
137
+ PARTICULAR PURPOSE. You are solely responsible for determining the
138
+ appropriateness of using or redistributing the Work and assume any risks
139
+ associated with Your exercise of permissions under this License.
140
+
141
+ 8. Limitation of Liability. In no event and under no legal theory, whether in
142
+ tort (including negligence), contract, or otherwise, unless required by
143
+ applicable law (such as deliberate and grossly negligent acts) or agreed to in
144
+ writing, shall any Contributor be liable to You for damages, including any
145
+ direct, indirect, special, incidental, or consequential damages of any
146
+ character arising as a result of this License or out of the use or inability to
147
+ use the Work (including but not limited to damages for loss of goodwill, work
148
+ stoppage, computer failure or malfunction, or any and all other commercial
149
+ damages or losses), even if such Contributor has been advised of the
150
+ possibility of such damages.
151
+
152
+ 9. Accepting Warranty or Additional Liability. While redistributing the Work
153
+ or Derivative Works thereof, You may choose to offer, and charge a fee for,
154
+ acceptance of support, warranty, indemnity, or other liability obligations
155
+ and/or rights consistent with this License. However, in accepting such
156
+ obligations, You may act only on Your own behalf and on Your sole
157
+ responsibility, not on behalf of any other Contributor, and only if You agree
158
+ to indemnify, defend, and hold each Contributor harmless for any liability
159
+ incurred by, or claims asserted against, such Contributor by reason of your
160
+ accepting any such warranty or additional liability.
161
+
162
+ END OF TERMS AND CONDITIONS
163
+
164
+ APPENDIX: How to apply the Apache License to your work.
165
+
166
+ Copyright 2026 Munim Technologies
167
+
168
+ Licensed under the Apache License, Version 2.0 (the "License");
169
+ you may not use this file except in compliance with the License.
170
+ You may obtain a copy of the License at
171
+
172
+ https://www.apache.org/licenses/LICENSE-2.0
173
+
174
+ Unless required by applicable law or agreed to in writing, software
175
+ distributed under the License is distributed on an "AS IS" BASIS,
176
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
177
+ See the License for the specific language governing permissions and
178
+ limitations under the License.
@@ -0,0 +1,41 @@
1
+ require "json"
2
+
3
+ package = JSON.parse(File.read(File.join(__dir__, "package.json")))
4
+
5
+ Pod::Spec.new do |s|
6
+ s.name = "NitroMunimFfmpeg"
7
+ s.version = package["version"]
8
+ s.summary = package["description"]
9
+ s.homepage = package["homepage"]
10
+ s.license = package["license"]
11
+ s.authors = package["author"]
12
+
13
+ s.platforms = { :ios => min_ios_version_supported }
14
+ s.source = { :git => "https://github.com/munimtechnologies/munim-ffmpeg.git", :tag => "v#{s.version}" }
15
+
16
+ s.source_files = [
17
+ # Implementation (Swift)
18
+ "ios/**/*.{swift}",
19
+ # Autolinking/Registration (Objective-C++)
20
+ "ios/**/*.{m,mm}",
21
+ # Implementation (C++ objects)
22
+ "cpp/**/*.{hpp,cpp}",
23
+ ]
24
+
25
+ load 'nitrogen/generated/ios/NitroMunimFfmpeg+autolinking.rb'
26
+ add_nitrogen_files(s)
27
+
28
+ s.dependency 'React-jsi'
29
+ s.dependency 'React-callinvoker'
30
+ s.dependency 'ffmpeg-kit-ios-https-alt', '6.0'
31
+
32
+ # ffmpeg-kit 6.0 declares negative Level values with an unsigned backing type.
33
+ # Xcode 26 rejects that header when Nitro enables Swift C++ interoperability.
34
+ s.script_phase = {
35
+ :name => 'Patch FFmpegKit Level enum for Xcode 26',
36
+ :script => '"${RUBY_EXECUTABLE:-/usr/bin/ruby}" "${PODS_TARGET_SRCROOT}/scripts/patch-ffmpegkit-level.rb"',
37
+ :execution_position => :before_compile,
38
+ }
39
+
40
+ install_modules_dependencies(s)
41
+ end
package/README.md ADDED
@@ -0,0 +1,95 @@
1
+ # munim-ffmpeg
2
+
3
+ Fast FFmpeg and FFprobe for Expo and React Native, powered by [Nitro Modules](https://nitro.margelo.com/).
4
+
5
+ ## Features
6
+
7
+ - Execute FFmpeg and FFprobe with argument arrays—no shell-string escaping.
8
+ - Receive FFmpeg logs and encoding statistics in JavaScript.
9
+ - Inspect media as parsed FFprobe JSON.
10
+ - Cancel one session or all active sessions.
11
+ - Autolinks in Expo development builds and bare React Native apps.
12
+
13
+ ## Installation
14
+
15
+ ```sh
16
+ npx expo install munim-ffmpeg react-native-nitro-modules
17
+ ```
18
+
19
+ This package contains native code, so it does not run in Expo Go. Create a development build after installing it:
20
+
21
+ ```sh
22
+ npx expo prebuild
23
+ npx expo run:ios
24
+ # or
25
+ npx expo run:android
26
+ ```
27
+
28
+ ## Usage
29
+
30
+ ```ts
31
+ import {
32
+ cancel,
33
+ execute,
34
+ getFFmpegVersion,
35
+ getMediaInformation,
36
+ probe,
37
+ } from 'munim-ffmpeg'
38
+
39
+ let activeSessionId: number | undefined
40
+
41
+ const execution = execute(
42
+ ['-i', inputUri, '-c:v', 'mpeg4', '-c:a', 'aac', outputUri],
43
+ (message) => console.log(message),
44
+ (timeMs, sizeBytes, bitrateKbits, speed) => {
45
+ console.log({ timeMs, sizeBytes, bitrateKbits, speed })
46
+ },
47
+ (sessionId) => {
48
+ activeSessionId = sessionId
49
+ }
50
+ )
51
+
52
+ // From a cancel button while the command is running:
53
+ if (activeSessionId !== undefined) cancel(activeSessionId)
54
+
55
+ const result = await execution
56
+
57
+ if (!result.success) {
58
+ throw new Error(result.failStackTrace ?? result.output)
59
+ }
60
+
61
+ const information = await getMediaInformation(inputUri)
62
+ const probeResult = await probe(['-v', 'error', '-show_streams', inputUri])
63
+ const version = getFFmpegVersion()
64
+ ```
65
+
66
+ Use native filesystem paths or `file://` URIs that the app can access. Android `content://` input may need to be copied into application storage first.
67
+
68
+ ## API
69
+
70
+ - `execute(arguments, onLog?, onStatistics?, onSessionCreated?)` returns `Promise<FFmpegSessionResult>`.
71
+ - `probe(arguments, onLog?, onSessionCreated?)` returns `Promise<FFmpegSessionResult>`.
72
+ - `getMediaInformation(path)` returns parsed FFprobe JSON.
73
+ - `cancel(sessionId?)` cancels one running session using the ID from `onSessionCreated`, or all sessions when no ID is supplied.
74
+ - `cancelAll()` cancels all sessions.
75
+ - `getFFmpegVersion()` returns the bundled FFmpeg version.
76
+
77
+ ## Native dependencies and licensing
78
+
79
+ The JavaScript and native bridge code in this repository is Apache-2.0 licensed. The distributed native FFmpeg dependencies are separate works with their own licenses:
80
+
81
+ - Android: `io.github.jamaismagic.ffmpeg:ffmpeg-kit-main-16kb:6.1.4`
82
+ - iOS: `ffmpeg-kit-ios-https-alt` 6.0
83
+
84
+ Those packages are FFmpegKit-compatible builds. FFmpeg and optional linked libraries may impose LGPL, GPL, attribution, or source-offer obligations depending on the build and codecs you distribute. Review the dependency licenses for your application before shipping.
85
+
86
+ ## Requirements
87
+
88
+ - Expo development build or bare React Native app with the New Architecture enabled
89
+ - React Native Nitro Modules
90
+ - iOS 15.1 or newer (as determined by the React Native minimum)
91
+ - Android API 24 or newer
92
+
93
+ ## License
94
+
95
+ Apache-2.0
@@ -0,0 +1,29 @@
1
+ project(NitroMunimFfmpeg)
2
+ cmake_minimum_required(VERSION 3.9.0)
3
+
4
+ set (PACKAGE_NAME NitroMunimFfmpeg)
5
+ set (CMAKE_VERBOSE_MAKEFILE ON)
6
+ set (CMAKE_CXX_STANDARD 20)
7
+
8
+ # Define C++ library and add all sources
9
+ add_library(${PACKAGE_NAME} SHARED
10
+ src/main/cpp/cpp-adapter.cpp
11
+ )
12
+
13
+ # Add Nitrogen specs :)
14
+ include(${CMAKE_SOURCE_DIR}/../nitrogen/generated/android/NitroMunimFfmpeg+autolinking.cmake)
15
+
16
+ # Set up local includes
17
+ include_directories(
18
+ "src/main/cpp"
19
+ "../cpp"
20
+ )
21
+
22
+ find_library(LOG_LIB log)
23
+
24
+ # Link all libraries together
25
+ target_link_libraries(
26
+ ${PACKAGE_NAME}
27
+ ${LOG_LIB}
28
+ android # <-- Android core
29
+ )
@@ -0,0 +1,144 @@
1
+ buildscript {
2
+ repositories {
3
+ google()
4
+ mavenCentral()
5
+ }
6
+
7
+ dependencies {
8
+ classpath "com.android.tools.build:gradle:9.3.1"
9
+ }
10
+ }
11
+
12
+ def reactNativeArchitectures() {
13
+ def value = rootProject.getProperties().get("reactNativeArchitectures")
14
+ return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
15
+ }
16
+
17
+ def isNewArchitectureEnabled() {
18
+ return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
19
+ }
20
+
21
+ apply plugin: "com.android.library"
22
+ apply plugin: 'org.jetbrains.kotlin.android'
23
+ apply from: '../nitrogen/generated/android/NitroMunimFfmpeg+autolinking.gradle'
24
+ apply from: "./fix-prefab.gradle"
25
+
26
+ if (isNewArchitectureEnabled()) {
27
+ apply plugin: "com.facebook.react"
28
+ }
29
+
30
+ def getExtOrDefault(name) {
31
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["NitroMunimFfmpeg_" + name]
32
+ }
33
+
34
+ def getExtOrIntegerDefault(name) {
35
+ return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["NitroMunimFfmpeg_" + name]).toInteger()
36
+ }
37
+
38
+ android {
39
+ namespace "com.margelo.nitro.munimffmpeg"
40
+
41
+ ndkVersion getExtOrDefault("ndkVersion")
42
+ compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
43
+
44
+ defaultConfig {
45
+ minSdkVersion getExtOrIntegerDefault("minSdkVersion")
46
+ targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
47
+ buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
48
+
49
+ externalNativeBuild {
50
+ cmake {
51
+ cppFlags "-frtti -fexceptions -Wall -Wextra -fstack-protector-all"
52
+ arguments "-DANDROID_STL=c++_shared", "-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON"
53
+ abiFilters (*reactNativeArchitectures())
54
+
55
+ buildTypes {
56
+ debug {
57
+ cppFlags "-O1 -g"
58
+ }
59
+ release {
60
+ cppFlags "-O2"
61
+ }
62
+ }
63
+ }
64
+ }
65
+ }
66
+
67
+ externalNativeBuild {
68
+ cmake {
69
+ path "CMakeLists.txt"
70
+ }
71
+ }
72
+
73
+ packagingOptions {
74
+ excludes = [
75
+ "META-INF",
76
+ "META-INF/**",
77
+ "**/libc++_shared.so",
78
+ "**/libNitroModules.so",
79
+ "**/libfbjni.so",
80
+ "**/libjsi.so",
81
+ "**/libfolly_json.so",
82
+ "**/libfolly_runtime.so",
83
+ "**/libglog.so",
84
+ "**/libhermes.so",
85
+ "**/libhermes-executor-debug.so",
86
+ "**/libhermes_executor.so",
87
+ "**/libreactnative.so",
88
+ "**/libreactnativejni.so",
89
+ "**/libturbomodulejsijni.so",
90
+ "**/libreact_nativemodule_core.so",
91
+ "**/libjscexecutor.so"
92
+ ]
93
+ }
94
+
95
+ buildFeatures {
96
+ buildConfig true
97
+ prefab true
98
+ }
99
+
100
+ buildTypes {
101
+ release {
102
+ minifyEnabled false
103
+ }
104
+ }
105
+
106
+ lintOptions {
107
+ disable "GradleCompatible"
108
+ }
109
+
110
+ compileOptions {
111
+ sourceCompatibility JavaVersion.VERSION_1_8
112
+ targetCompatibility JavaVersion.VERSION_1_8
113
+ }
114
+
115
+ sourceSets {
116
+ main {
117
+ if (isNewArchitectureEnabled()) {
118
+ java.srcDirs += [
119
+ // React Codegen files
120
+ "${project.buildDir}/generated/source/codegen/java"
121
+ ]
122
+ }
123
+ }
124
+ }
125
+ }
126
+
127
+ repositories {
128
+ mavenCentral()
129
+ google()
130
+ }
131
+
132
+
133
+ dependencies {
134
+ // For < 0.71, this will be from the local maven repo
135
+ // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
136
+ //noinspection GradleDynamicVersion
137
+ implementation "com.facebook.react:react-native:+"
138
+
139
+ // Add a dependency on NitroModules
140
+ implementation project(":react-native-nitro-modules")
141
+
142
+ // Maintained FFmpegKit-compatible Android artifact with 16 KB page support.
143
+ implementation "io.github.jamaismagic.ffmpeg:ffmpeg-kit-main-16kb:6.1.4"
144
+ }
@@ -0,0 +1,51 @@
1
+ tasks.configureEach { task ->
2
+ // Make sure that we generate our prefab publication file only after having built the native library
3
+ // so that not a header publication file, but a full configuration publication will be generated, which
4
+ // will include the .so file
5
+
6
+ def prefabConfigurePattern = ~/^prefab(.+)ConfigurePackage$/
7
+ def matcher = task.name =~ prefabConfigurePattern
8
+ if (matcher.matches()) {
9
+ def variantName = matcher[0][1]
10
+ task.outputs.upToDateWhen { false }
11
+ task.dependsOn("externalNativeBuild${variantName}")
12
+ }
13
+ }
14
+
15
+ afterEvaluate {
16
+ def abis = reactNativeArchitectures()
17
+ rootProject.allprojects.each { proj ->
18
+ if (proj === rootProject) return
19
+
20
+ def dependsOnThisLib = proj.configurations.findAll { it.canBeResolved }.any { config ->
21
+ config.dependencies.any { dep ->
22
+ dep.group == project.group && dep.name == project.name
23
+ }
24
+ }
25
+ if (!dependsOnThisLib && proj != project) return
26
+
27
+ if (!proj.plugins.hasPlugin('com.android.application') && !proj.plugins.hasPlugin('com.android.library')) {
28
+ return
29
+ }
30
+
31
+ def variants = proj.android.hasProperty('applicationVariants') ? proj.android.applicationVariants : proj.android.libraryVariants
32
+ // Touch the prefab_config.json files to ensure that in ExternalNativeJsonGenerator.kt we will re-trigger the prefab CLI to
33
+ // generate a libnameConfig.cmake file that will contain our native library (.so).
34
+ // See this condition: https://cs.android.com/android-studio/platform/tools/base/+/mirror-goog-studio-main:build-system/gradle-core/src/main/java/com/android/build/gradle/tasks/ExternalNativeJsonGenerator.kt;l=207-219?q=createPrefabBuildSystemGlue
35
+ variants.all { variant ->
36
+ def variantName = variant.name
37
+ abis.each { abi ->
38
+ def searchDir = new File(proj.projectDir, ".cxx/${variantName}")
39
+ if (!searchDir.exists()) return
40
+ def matches = []
41
+ searchDir.eachDir { randomDir ->
42
+ def prefabFile = new File(randomDir, "${abi}/prefab_config.json")
43
+ if (prefabFile.exists()) matches << prefabFile
44
+ }
45
+ matches.each { prefabConfig ->
46
+ prefabConfig.setLastModified(System.currentTimeMillis())
47
+ }
48
+ }
49
+ }
50
+ }
51
+ }
@@ -0,0 +1,5 @@
1
+ NitroMunimFfmpeg_kotlinVersion=2.1.21
2
+ NitroMunimFfmpeg_minSdkVersion=24
3
+ NitroMunimFfmpeg_targetSdkVersion=36
4
+ NitroMunimFfmpeg_compileSdkVersion=36
5
+ NitroMunimFfmpeg_ndkVersion=29.0.14206865
@@ -0,0 +1,2 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
+ </manifest>
@@ -0,0 +1,9 @@
1
+ #include <jni.h>
2
+ #include <fbjni/fbjni.h>
3
+ #include "NitroMunimFfmpegOnLoad.hpp"
4
+
5
+ JNIEXPORT jint JNICALL JNI_OnLoad(JavaVM* vm, void*) {
6
+ return facebook::jni::initialize(vm, []() {
7
+ margelo::nitro::munimffmpeg::registerAllNatives();
8
+ });
9
+ }