Skip to content

Commit ea7b52d

Browse files
Support aar dependency
1 parent 353a2f4 commit ea7b52d

File tree

7 files changed

+189
-11
lines changed

7 files changed

+189
-11
lines changed

README.md

Lines changed: 168 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,130 @@ FFmpeg Android runs on the following architectures:
6262
### Dependency
6363
- [MobileFFmpeg](https://github.com/tanersener/mobile-ffmpeg)
6464

65-
### Gradle Dependency
66-
* Add it in your root build.gradle at the end of repositories:
65+
**Note:** This library includes the mobile-ffmpeg.aar file (full version) in the `SSffmpegVideoOperation/libs/` directory. The full version includes all FFmpeg features and codecs needed for comprehensive video operations.
6766

68-
```
67+
**For JitPack users:** The mobile-ffmpeg dependency is automatically included when you use the JitPack dependency. No additional setup required!
68+
69+
### Integration Guide
70+
71+
This library uses the mobile-ffmpeg AAR dependency which is included in the library's libs folder. Follow these simple steps to integrate the library into your project.
72+
73+
#### Step 1: Download the Library
74+
* Download or clone this repository
75+
* Copy the `SSffmpegVideoOperation` module folder to your project
76+
77+
#### Step 2: Integration Methods
78+
79+
**Option A: Using JitPack (Recommended - Simple One-Line Integration)**
80+
81+
This is the easiest way to integrate the library. JitPack will build the library along with the mobile-ffmpeg dependency automatically.
82+
83+
* Add JitPack repository to your root build.gradle:
84+
85+
```gradle
6986
allprojects {
7087
repositories {
71-
...
88+
google()
89+
mavenCentral()
7290
maven { url 'https://jitpack.io' }
7391
}
7492
}
7593
```
7694

77-
* Add the dependency in your app's build.gradle file
95+
* Add the dependency in your app's build.gradle file:
7896

79-
```
97+
```gradle
8098
dependencies {
8199
implementation 'com.github.SimformSolutionsPvtLtd:SSffmpegVideoOperation:1.0.8'
82100
}
83101
```
84102

85-
This is all you have to do to load the FFmpeg library.
103+
**That's it!** JitPack will automatically handle the mobile-ffmpeg.aar dependency that's included in this repository. No additional configuration needed.
104+
105+
**Option B: Local Integration (For Customization)**
106+
107+
If you want to modify the library or integrate it locally, follow these steps:
108+
109+
1. **Add the library module to your `settings.gradle`:**
110+
```gradle
111+
include ':app', ':SSffmpegVideoOperation'
112+
// If the SSffmpegVideoOperation folder is in a different location:
113+
// project(':SSffmpegVideoOperation').projectDir = new File('path/to/SSffmpegVideoOperation')
114+
```
115+
116+
2. **Configure repositories in your app's `build.gradle`:**
117+
```gradle
118+
android {
119+
// ... your existing configuration
120+
}
121+
122+
repositories {
123+
google()
124+
mavenCentral()
125+
flatDir {
126+
dirs '../SSffmpegVideoOperation/libs'
127+
}
128+
}
129+
130+
dependencies {
131+
implementation project(':SSffmpegVideoOperation')
132+
// ... your other dependencies
133+
}
134+
```
135+
136+
3. **The SSffmpegVideoOperation module is already configured with:**
137+
- `libs/mobile-ffmpeg.aar` - The full version of mobile-ffmpeg
138+
- Proper repository configuration in its `build.gradle`:
139+
```gradle
140+
repositories {
141+
flatDir {
142+
dirs 'libs'
143+
}
144+
}
145+
146+
dependencies {
147+
implementation(name: 'mobile-ffmpeg', ext: 'aar')
148+
// ... other dependencies
149+
}
150+
```
151+
152+
**Important Notes:**
153+
- The `mobile-ffmpeg.aar` file is already included in `SSffmpegVideoOperation/libs/`
154+
- No additional setup is required for the AAR dependency
155+
- The library uses `flatDir` repository to resolve the local AAR file
156+
- Make sure to sync your project after adding the module
157+
158+
## How JitPack Integration Works
159+
160+
When you use the JitPack dependency (`implementation 'com.github.SimformSolutionsPvtLtd:SSffmpegVideoOperation:1.0.8'`):
161+
162+
1. **JitPack automatically builds** your library from the GitHub repository
163+
2. **Includes mobile-ffmpeg.aar** - The AAR file in `SSffmpegVideoOperation/libs/` is packaged with the library
164+
3. **Resolves dependencies** - All transitive dependencies are handled automatically
165+
4. **No local setup needed** - Users don't need to manually handle AAR files or repository configurations
166+
167+
This approach gives you the best of both worlds:
168+
- **Simple integration** for users via JitPack
169+
- **Full control** over the mobile-ffmpeg dependency
170+
- **No external dependencies** on repositories that might change or become unavailable
171+
172+
#### Step 3: Add Required Permissions
173+
Add these permissions to your AndroidManifest.xml:
174+
```xml
175+
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
176+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
177+
<uses-permission android:name="android.permission.CAMERA" />
178+
<uses-permission android:name="android.permission.RECORD_AUDIO" />
179+
```
180+
181+
#### Step 4: ProGuard Configuration (if using ProGuard/R8)
182+
Add these rules to your proguard-rules.pro:
183+
```
184+
-keep class com.arthenica.mobileffmpeg.** { *; }
185+
-keep class com.simform.videooperations.** { *; }
186+
```
187+
188+
This setup ensures proper AAR dependency resolution and avoids the "Direct local .aar file dependencies are not supported" error when building AAR libraries.
86189

87190
### Run FFmpeg command
88191
In this sample code we will run the FFmpeg -version command in background call.
@@ -138,6 +241,64 @@ CallBackOfQuery().callQuery(query, object : FFmpegCallBack {
138241
same for other queries.
139242
And you can apply your query also
140243

244+
## Troubleshooting
245+
246+
### Common Issues and Solutions
247+
248+
#### 1. "Could not find mobile-ffmpeg.aar" Error
249+
**Solution:**
250+
- Ensure the `SSffmpegVideoOperation/libs/mobile-ffmpeg.aar` file exists
251+
- Check that your app's build.gradle has the correct flatDir repository configuration:
252+
```gradle
253+
repositories {
254+
flatDir {
255+
dirs '../SSffmpegVideoOperation/libs'
256+
}
257+
}
258+
```
259+
260+
#### 2. "INSTALL_PARSE_FAILED_NO_CERTIFICATES" Error
261+
**Solution:** Ensure your release builds are properly signed. Add signing configuration to your app's build.gradle:
262+
```gradle
263+
android {
264+
signingConfigs {
265+
debug {
266+
storeFile file("${System.getProperty('user.home')}/.android/debug.keystore")
267+
storePassword "android"
268+
keyAlias "androiddebugkey"
269+
keyPassword "android"
270+
}
271+
}
272+
buildTypes {
273+
release {
274+
signingConfig signingConfigs.debug // Use debug signing for testing
275+
// For production, create and use a proper release keystore
276+
}
277+
}
278+
}
279+
```
280+
281+
#### 3. Build Sync Issues
282+
**Solution:**
283+
- Make sure the SSffmpegVideoOperation module is properly included in settings.gradle
284+
- Verify the module path is correct
285+
- Clean and rebuild the project
286+
287+
#### 4. FFmpeg Commands Not Working
288+
**Solution:**
289+
- Check if you have the required permissions
290+
- Ensure input and output file paths are correct and accessible
291+
- Verify the FFmpeg command syntax
292+
293+
#### 5. Memory Issues with Large Videos
294+
**Solution:**
295+
- Process videos in smaller chunks
296+
- Use appropriate compression settings
297+
- Consider using background processing for large files
298+
299+
#### 6. "flatDir should be avoided" Warning
300+
**Solution:** This warning can be ignored. While flatDir is not the recommended approach for published libraries, it's acceptable for local AAR dependencies and works reliably for this use case.
301+
141302
## Medium Blog
142303
For more info go to __[Multimedia Operations for Android using FFmpeg](https://medium.com/simform-engineering/multimedia-operations-for-android-using-ffmpeg-78f1fb480a83)__
143304

SSffmpegVideoOperation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
/captures
1010
.externalNativeBuild
1111
libs/
12+
!libs/mobile-ffmpeg.aar
1213
.idea/gradle.xml
1314
.idea/misc.xml
1415
.idea/modules.xml

SSffmpegVideoOperation/build.gradle

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ afterEvaluate {
1919
}
2020

2121
repositories {
22+
google()
23+
mavenCentral()
2224
flatDir {
2325
dirs 'libs'
2426
}
@@ -72,7 +74,6 @@ dependencies {
7274
implementation 'androidx.appcompat:appcompat:1.7.1'
7375
implementation 'com.google.android.material:material:1.12.0'
7476
implementation 'pub.devrel:easypermissions:3.0.0'
75-
implementation(files("libs/mobile-ffmpeg.aar"))
77+
implementation (name: 'mobile-ffmpeg', ext: 'aar')
7678
implementation 'com.github.jaiselrahman:FilePicker:1.3.2'
7779
}
78-
46 MB
Binary file not shown.

app/build.gradle

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,20 @@ android {
1616
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
1717
}
1818

19+
signingConfigs {
20+
debug {
21+
storeFile file("${System.getProperty('user.home')}/.android/debug.keystore")
22+
storePassword 'android'
23+
keyAlias 'androiddebugkey'
24+
keyPassword 'android'
25+
}
26+
}
27+
1928
buildTypes {
2029
release {
2130
minifyEnabled false
2231
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
32+
signingConfig signingConfigs.debug
2333
}
2434
}
2535

@@ -39,6 +49,12 @@ android {
3949
flavorDimensions "default"
4050
}
4151

52+
repositories {
53+
flatDir {
54+
dirs '../SSffmpegVideoOperation/libs'
55+
}
56+
}
57+
4258
final roomSchemaDir = "$projectDir/roomSchemas"
4359

4460
kapt {

app/src/main/AndroidManifest.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
xmlns:tools="http://schemas.android.com/tools"
44
package="com.simform.videoimageeditor">
55

6-
<uses-permission android:name="android.permission.CAMERA" />
76
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"
87
android:maxSdkVersion="32" />
98
<uses-permission

jitpack.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
jdk:
2-
- openjdk11
2+
- openjdk8

0 commit comments

Comments
 (0)