最近项目需要使用到mp4v2,记录一下基于ndkexternalBuild的流程
1. 下载源码
这个项目比较老,貌似也没有人维护了,在git发现上面fork了不少版本,选择star最多的
TechSmith/mp4v2
2.删掉几个平台相关的文件
在编译时发现几个文件都是win平台相关,删掉才能用
libplatform/io/FileSystem_win32.cpp
libplatform/io/File_win32.cpp
3.修改获取时间函数
milliseconds_tgetLocalTimeMilliseconds(){
timeval buf;
if( gettimeofday( &buf, 0 ))
memset( &buf, 0, sizeof( buf ));
return milliseconds_t( buf.tv_sec ) * 1000 + buf.tv_usec / 1000;
}
4.最终CMakeLists.txt
只需要把里面的${mp4v2_DIR}
变量路径替换一下,就能跑了
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_VERBOSE_MAKEFILE on)
set(mp4v2_DIR ${CMAKE_SOURCE_DIR}/src/main/cpp/mp4v2)
file(GLOB mp4v2src ${mp4v2_DIR}/src/*.cpp)
file(GLOB mp4v2src_bmff ${mp4v2_DIR}/src/bmff/*.cpp)
file(GLOB mp4v2src_itmf ${mp4v2_DIR}/src/itmf/*.cpp)
file(GLOB mp4v2src_qtff ${mp4v2_DIR}/src/qtff/*.cpp)
file(GLOB mp4v2util ${mp4v2_DIR}/util/*.cpp)
file(GLOB mp4v2libutil "${mp4v2_DIR}/libutil/*.cpp")
file(GLOB mp4v2libplatform "${mp4v2_DIR}/libplatform/*.cpp")
file(GLOB mp4v2libplatform_time "${mp4v2_DIR}/libplatform/time/*.cpp")
file(GLOB mp4v2libplatform_number "${mp4v2_DIR}/libplatform/number/*.cpp")
file(GLOB mp4v2libplatform_io "${mp4v2_DIR}/libplatform/io/*.cpp")
file(GLOB mp4v2libplatform_process "${mp4v2_DIR}/libplatform/process/*.cpp")
file(GLOB mp4v2libplatform_prog "${mp4v2_DIR}/libplatform/prog/*.cpp")
file(GLOB mp4v2libplatform_sys "${mp4v2_DIR}/libplatform/sys/*.cpp")
include_directories(${mp4v2_DIR}
${mp4v2_DIR}/include)
add_library( # Sets the name of the library.
mp4v2
# Sets the library as a shared library.
STATIC
# Provides a relative path to your source file(s).
# Associated headers in the same location as their source
# file are automatically included.
${mp4v2src}
${mp4v2src_bmff}
${mp4v2src_itmf}
${mp4v2src_qtff}
${mp4v2util}
${mp4v2libplatform}
${mp4v2libplatform_time}
${mp4v2libplatform_number}
${mp4v2libplatform_io}
${mp4v2libplatform_prog}
${mp4v2libplatform_sys}
${mp4v2libutil}
)