创建一个AndroID项目,添加c++支持
静态库复制到制定目录
支持的平台
加载文件的目录
externalNativeBuild { cmake { path "src/main/cpp/CMakeLists.txt" version "3.10.2" } }
配置文件
cmake_minimum_required(VERSION 3.10.2)project("ffmpeddemo")set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11")set(libs ${CMAKE_SOURCE_DIR}/../libs)set(libname play) #编译之后的名字 不一样要和文件名相同#编译的文件 在include文件夹下、、、include_directorIEs( include play utils play/decor play/decor/base# ${CMAKE_SOURCE_DIR}/util)link_directorIEs( ${libs}/${ANDROID_ABI})#编译那些文件file(GLOB src-files ${CMAKE_SOURCE_DIR}/*.cpp ${CMAKE_SOURCE_DIR}/play/*.cpp ${CMAKE_SOURCE_DIR}/play/*.h ${CMAKE_SOURCE_DIR}/utils/*.cpp ${CMAKE_SOURCE_DIR}/utils/*.h ${CMAKE_SOURCE_DIR}/play/decor/*.cpp ${CMAKE_SOURCE_DIR}/play/decor/*.h ${CMAKE_SOURCE_DIR}/play/decor/base/*.cpp ${CMAKE_SOURCE_DIR}/play/decor/base/*.h )add_library( # Sets the name of the library. ${libname} # Sets the library as a shared library. SHARED # ProvIDes a relative path to your source file(s). ${src-files} #加入的就是上面指定文件下的所有 )set(third-party-libs avformat avcodec avfilter swresample swscale avutil fdk-aac x264 )set(native-libs androID log OpenSLES )target_link_librarIEs( # SpecifIEs the target library. ${libname} ${log-lib} ${third-party-libs} ${native-libs} androID z )
编写测试代码
extern "C"JNIEXPORT Jstring JNICALLJava_com_kangwang_ffmpeddemo_FFmpegdiaPlayer_native_1version(jnienv *env, jobject thiz) { string hello = av_version_info(); string avutil = to_string(avutil_version()); hello.append(avutil); LOGCATI("avutil"); return env->NewStringUTF(hello.c_str());}
java层测试代码
public String versionInfo() { return native_version(); } private native String native_version();
https://github.com/wangwangla/learnffmpeg
总结
以上是内存溢出为你收集整理的Android搭建ffmpeg环境全部内容,希望文章能够帮你解决Android搭建ffmpeg环境所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)