I try to build and use FFmpeg Library on Android Studio.
My Environments
Windows 7 64bit, Cygwin64, Android Studtio 2.1.2, FFmpeg 3.1.1, Android NDK r12b
Ref. Page
http://www.roman10.net/2013/08/18/how-to-build-ffmpeg-with-ndk-r9/ I follow this page.
I succeed FFmpeg library build using ./build_android.sh on Cygwin
so I try to use FFmpeg Library's on Android Studio.
Setting Android Studio for use FFmpeg
my project_path/jni/Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg_trim
LOCAL_SRC_FILES := ffmpeg_trim.c
LOCAL_LDLIBS := -lz -ljnigraphics
LOCAL_SHARED_LIBRARIES := libavformat libavcodec libavutil libswscale libswresample
LOCAL_EXPORT_C_INCLUDES := ($LOCAL_PATH)/include
include $(BUILD_SHARED_LIBRARY)
$(call import-module,ffmpeg-3.1.1/android/arm)
my jni/Application.mk
APP_ABI := armeabi-v7a
my project_path/jni/ffmpeg_trim.c
#include "my_package_util_TrimUtil.h"
#include <libavformat/avformat.h>
JNIEXPORT void JNICALL
Java_my_package_videoeditor_util_TrimUtil_registerAll(JNIEnv *env, jobject obj)
{
av_register_all();
}
my project_path/jni/ffmpeg_trim.h
/* DO NOT EDIT THIS FILE - it is machine generated */
#include <jni.h>
/* Header for class my_package_videoeditor_util_TrimUtil */
#ifndef _Included_my_package_videoeditor_util_TrimUtil
#define _Included_my_package_videoeditor_util_TrimUtil
#ifdef __cplusplus
extern "C" {
#endif
/*
* Class: my_package_videoeditor_util_TrimUtil
* Method: registerAll
* Signature: ()V
*/
JNIEXPORT void JNICALL Java_my_package_util_TrimUtil_registerAll
(JNIEnv *, jobject);
#ifdef __cplusplus
}
#endif
#endif
my project_path/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "my.package.videoeditor"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
mp4parser {
applicationIdSuffix ".mp4parser"
}
ffmpeg {
applicationIdSuffix ".ffmpeg"
ndk {
moduleName "ffmpeg_trim"
cFlags "-std=c99 -I${project.buildDir}/../src/ffmpeg/jni/include"
}
sourceSets.main {
jni.srcDirs = []
jniLibs.srcDir 'src/ffmpeg/libs'
}
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.googlecode.mp4parser:isoparser:1.1.21'
}
my project_path/jni folder
I build my Project.
But, failed and print this message.
I can't solve my problem. How to build and use FFmpeg Library on Android Studio.
Don't tell me other libraries using FFmpeg.