Source: Me, GitHub, following this for update GitHub
Question: How to fucking add JavaCV to Android Studio so I can use the fucking annoying FFmpeg?
Answer: This tut will use JavaCV 1.1, version 1.2 currently has SIGSEGV issue. JavaCV 1.1 comes with FFmpeg 2.8.1.
- Obtain the prebulit binaries here.
- Extract it and copy these files:
- javacpp.jar (essential).
- javacv.jar (essential).
- ffmpeg.jar (essential if you use FFmpeg).
- ffmpeg-android-arm.jar (for arm CPU).
- ffmpeg-android-x86.jar (optional for x86 CPU).
into the
libs
folder of your project (app/libs
in my case).
- Click on
app
->F4
->Dependencies
->+
->File dependencies
-> choose all the previous .jar. - Temporarily, because of this issue, we need to set
targetSdkVersion 22
the app'sbuild.gradle
. - Possibly need to set these
packagingOptions
in thebuild.gradle
:
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
exclude 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
//might need these if you use openCV
//exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
//exclude 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
}
}
To play overlay at different time, see second link.
This worked to get javacv and ffmpeg to work for me! However I was using Kotlin and had to do some other steps. Instead of 3 I used
implementation(fileTree(mapOf("dir" to "libs", "include" to listOf("*.jar"))))
in the build.gradle file.I also had to add
android:extractNativeLibs="true"
to the application part AndroidManifest.xml. After that it worked.It might not even be needed to download the jars anymore and just import packages from Gradle directly. I think the modification to the xml was the key part for it to work. But following these steps worked for me.