Android Studio2.2.3 Reference FFmpeg Library summary via JNI

Source: Internet
Author: User

To modify a step:

    1. First compile the libffmpeg.so with NDK14 and take out the Include directory

    2. 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.