To modify a step:
First compile the libffmpeg.so with NDK14 and take out the Include directory
Create a JNI-based project with AS, put the include directory under the CPP, build the Jnilibs/armeabi directory, and put the libffmpeg.so inside
650) this.width=650; "Src=" https://s1.51cto.com/wyfs02/M00/9B/C7/wKiom1lnD5Sh5vzsAABjn9nLj1w935.jpg-wh_500x0-wm_ 3-wmp_4-s_4100660184.jpg "title=" 36020170713141223334.jpg "alt=" Wkiom1lnd5sh5vzsaabjn9nlj1w935.jpg-wh_50 "/>
3. Configure CMakeLists.txt
Add the following:
#add the FFmpeg Lib
Include_directories (${cmake_current_source_dir}/src/main/cpp/include)
Add_library (ffmpeg-lib SHARED imported)
Set_target_properties (Ffmpeg-lib Properties Imported_location ${cmake_current_source_dir}/src/main/jnilibs/ armeabi/libffmpeg.so)
targ Et_link_libraries ( native-lib
ffmpeg-lib #ffmpeg lib
android #use the Android log lib
${log-lib} )
4. Configure Build.gradle
Major additions to arguments and NDK configurations
Externalnativebuild {cmake {cppflags "" arguments '-dandroid_toolchain=clang ', '-dandroid_stl=gnustl_st Atic '} ndk {abifilters ' Armeabi '}}
5.native_lib.cpp
#include <jni.h>
#include <string>
#include <android/log.h>
extern "C"
{
#include "libavcodec/avcodec.h"
#include "Libavformat/avformat.h"
#include "libswscale/swscale.h"
#include "Libavutil/imgutils.h"
#include "libavutil/avutil.h"
}
#define LOG_TAG "Mytagffmpeg"
#define ALOGE (...) __android_log_print (Android_log_debug, Log_tag, __va_args__)
extern "C"
Jstring
Java_letv_com_myffmpeg_mainactivityffmpeg_stringfromjni (
JNIEnv *env,
Jobject/* This */) {
std::string Hello = "Hello, this is the first ffmpeg test!";
Aloge ("%s", Hello.c_str ());
Char info[10000] = {0};
sprintf (Info, "%s\n", Avcodec_configuration ());
Hello + = info;
Return Env->newstringutf (Hello.c_str ());
}
That's all.
This article is from the "focus on embedded multimedia Technology" blog, please be sure to keep this source http://zyg0227.blog.51cto.com/1043164/1947097
Android Studio2.2.3 Reference FFmpeg Library summary via JNI