How to use FFmpeg built by VPlayer in Android Studio?
Source: GitHub
Question: How to use FFmpeg built by VPlayer (version 0.3.2 at the time I write this Gist) in Android Studio?
Answer This will take the FFmpeg built from here and use it as a library for our project in Android Stuio in Window 10.
C:\Users\Viet\AppData\Local\Android\ndk\android-ndk-r11c
in my case).VPlayer_lib
folder build from here into the root of your project.app -> F4 -> SDK Location -> Android NDK location
.gradle.properties
file in the root folder of your project with android.useDeprecatedNdk=true
.settings.gradle
and add these two lines at the bottominclude ':VPlayer_library'
project(':VPlayer_library').projectDir = new File(settingsDir, 'VPlayer_lib/VPlayer_library')
build.gradle
file to add the dependency by adding this:dependencies {
...
compile project(':VPlayer_library')
...
}
VPlayer_lib
folder (this should add folders to VPlayer_library/jni/
)/{root}/VPlayer_lib/VPlayer_library/jni/setup.sh
.Your folder structure should look like this under /jni
jni/
|- android-ndk-profiler-3.1/
|- application/
|- ffmpeg/
|- ffmpeg-build/
|- libyuv/
|- tropicssl/
|- Android.mk
|- Android-tropicssl.mk
|- Application.mk
|- setup.sh
Application.mk
to change architectures.Android.mk
:FEATURE_NEON
: if you comment this, you need to remove NativeTester
code in VPlayerController.java@LINE292
. (leave this)SUBTITLES
: remove if you do not want subtitle support; if you download the binaries or built one without subtitles you must comment this out. (temporrary leave this as our FFmpeg come with subtitle, need to update it to a version without subtitles).MODULE_ENCRYPT
: remove if you do not want encryption for networking. (comment out)LIBRARY_PROFILER
: remove if you do not want the profiler. (leave this, I dont even know what this is).Are you sure your NDK_MODULE_PATH variable is properly defined ?
error, add the following to Android.mk
:...
$(call import-add-path,C:\Users\Viet\AppData\Local\Android\ndk\android-ndk-r11c\sources\android)
$(call import-module,cpufeatures)
of course this will need to be your path to the NDK, TRIPLE CHECK it don't be lazy.
gradle.properties
:org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
UnsatisfiedLinkError, libffmpeg-neon.so: has text relocations
. Temporary solution is to change the targetSDK of your app to anything smaller than 23.