Linux系统下编译mp4v2生成Android下使用的So文件
一、需求背景
之前一直用到了mp4v2这个库,使用库进行MP4的文件录制,一直使用 的是armeabi类型的so文件,后来由于AS的更新,将不再支持armeabi格式的so文件,所以才需要编译不同类型的so文件以支持项目的健壮性。而且armeabi-v7a的兼容性更好。
二、在Ubuntu下安装ndk环境
Android NDK 安装配置指南
可以根据安装指南初步编译sample工程。
三、编译mp4v2
通过第一步的sample工程的试手,我们可以知道,如果要编译工程,先需要编写对应的.mk文件。
1.android 编译mp4v2 2.0.0生成动态库
2.Android平台的Android.mk和Application.mk
第一个链接是百度上面找的,找了很多资料,很多都是参考第一个资料进行编译的。第二个资料是GITHUB上面的一个开源项目,看起来还不错,但是第二个作者将整个项目编译成了许多不同的小包。所以我需要将第一个和第二个进行整合一下。
1). 下载[2]中的项目,调整一下目录结构,在mp4v2-master目录下面新建jni目录,将其他文件都考入jni目录。
2). 将jni目录下的Android.mk里面的内容替换如下
#----------------------------------------------------
# Author: momo0853@live.com
# Time : 2016年 04月 20日 星期三 17:34:45 CST
#----------------------------------------------------
#
# This is an automatically generated file, in order to reduce repetitive work.
# Android.mk: For more details, please see "http://developer.android.com/ndk/guides/android_mk.html".
# Application.mk: For more details, please see "http://developer.android.com/ndk/guides/application_mk.html".
# Can identify the suffix for .c .cc .cpp and .a .so.
LOCAL_PATH := $(call my-dir)
libmp4v2_la_SOURCES := \
src/3gp.cpp \
src/atom_ac3.cpp \
src/atom_amr.cpp \
src/atom_avc1.cpp \
src/atom_avcC.cpp \
src/atom_chpl.cpp \
src/atom_colr.cpp \
src/atom_d263.cpp \
src/atom_dac3.cpp \
src/atom_damr.cpp \
src/atom_dref.cpp \
src/atom_elst.cpp \
src/atom_enca.cpp \
src/atom_encv.cpp \
src/atom_free.cpp \
src/atom_ftyp.cpp \
src/atom_ftab.cpp \
src/atom_gmin.cpp \
src/atom_hdlr.cpp \
src/atom_hinf.cpp \
src/atom_hnti.cpp \
src/atom_href.cpp \
src/atom_mdat.cpp \
src/atom_mdhd.cpp \
src/atom_meta.cpp \
src/atom_mp4s.cpp \
src/atom_mp4v.cpp \
src/atom_mvhd.cpp \
src/atom_nmhd.cpp \
src/atom_ohdr.cpp \
src/atom_pasp.cpp \
src/atom_root.cpp \
src/atom_rtp.cpp \
src/atom_s263.cpp \
src/atom_sdp.cpp \
src/atom_sdtp.cpp \
src/atom_smi.cpp \
src/atom_sound.cpp \
src/atom_standard.cpp \
src/atom_stbl.cpp \
src/atom_stdp.cpp \
src/atom_stsc.cpp \
src/atom_stsd.cpp \
src/atom_stsz.cpp \
src/atom_stz2.cpp \
src/atom_text.cpp \
src/atom_tfhd.cpp \
src/atom_tkhd.cpp \
src/atom_treftype.cpp \
src/atom_trun.cpp \
src/atom_tx3g.cpp \
src/atom_udta.cpp \
src/atom_url.cpp \
src/atom_urn.cpp \
src/atom_uuid.cpp \
src/atom_video.cpp \
src/atom_vmhd.cpp \
src/cmeta.cpp \
src/descriptors.cpp \
src/exception.cpp \
src/enum.tcc \
src/isma.cpp \
src/log.cpp \
src/mp4.cpp \
src/mp4atom.cpp \
src/mp4container.cpp \
src/mp4descriptor.cpp \
src/mp4file.cpp \
src/mp4file_io.cpp \
src/mp4info.cpp \
src/mp4property.cpp \
src/mp4track.cpp \
src/mp4util.cpp \
src/ocidescriptors.cpp \
src/odcommands.cpp \
src/qosqualifiers.cpp \
src/rtphint.cpp \
src/text.cpp \
libmp4v2_la_SOURCES += \
src/bmff/typebmff.cpp \
libmp4v2_la_SOURCES += \
src/itmf/CoverArtBox.cpp \
src/itmf/Tags.cpp \
src/itmf/generic.cpp \
src/itmf/type.cpp \
libmp4v2_la_SOURCES += \
src/qtff/ColorParameterBox.cpp \
src/qtff/PictureAspectRatioBox.cpp \
src/qtff/coding.cpp \
libmp4v2_la_SOURCES += \
libplatform/io/File.cpp \
libplatform/io/FileSystem.cpp \
libplatform/prog/option.cpp \
libplatform/sys/error.cpp \
libplatform/time/time.cpp \
libmp4v2_la_SOURCES += \
libplatform/io/File_posix.cpp \
libplatform/io/FileSystem_posix.cpp \
libplatform/number/random_posix.cpp \
libplatform/process/process_posix.cpp \
libplatform/time/time_posix.cpp
libmp4v2_la_SOURCES += \
libutil/Database.cpp \
libutil/Timecode.cpp \
libutil/TrackModifier.cpp \
libutil/Utility.cpp \
libutil/crc.cpp \
libutil/other.cpp \
include $(CLEAR_VARS)
LOCAL_MODULE := libmp4v2
LOCAL_ARM_MODULE := arm
LOCAL_CFLAGS := -fno-rtti -fexceptions
#LOCAL_EXPORT_CFLAGS := $(LOCAL_CFLAGS)
LOCAL_SRC_FILES := $(libmp4v2_la_SOURCES)
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
$(LOCAL_PATH)/vstudio9.0/include \
$(LOCAL_PATH)/libutil \
$(LOCAL_PATH)/libutil/include \
$(LOCAL_PATH)/libplatform \
$(LOCAL_PATH)/libplatform/include \
$(LOCAL_PATH)
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_C_INCLUDES)
#LOCAL_SHARED_LIBRARIES := \
# libutils \
# libbinder \
# libcutils
LOCAL_CXXFLAGS :=-fexceptions -Wno-write-strings
LOCAL_CPPFLAGS := -O2 -fexceptions -DHAVE_SOCKLEN_T -DHAVE_STRUCT_IOVEC
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
3). 进入到mp4v2-master/jni目录运行 ndk-build命令即可进行编译
4). 如果需要编译全部类型的so文件,只需要将Application.mk文件下面 APP_ABI 修改成all即可。
四、编译结果
chezi008@master:~/AndroidStudioProjects/mp4v2-master/jni$ ndk-build
Android NDK: WARNING: Unsupported source file extensions in Android.mk for module mp4v2
Android NDK: src/enum.tcc
[armeabi-v7a] Compile++ thumb: mp4v2 <= 3gp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_ac3.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_amr.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_avc1.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_avcC.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_chpl.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_colr.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_d263.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_dac3.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_damr.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_dref.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_elst.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_enca.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_encv.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_free.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_ftyp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_ftab.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_gmin.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_hdlr.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_hinf.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_hnti.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_href.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_mdat.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_mdhd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_meta.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_mp4s.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_mp4v.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_mvhd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_nmhd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_ohdr.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_pasp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_root.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_rtp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_s263.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_sdp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_sdtp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_smi.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_sound.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_standard.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_stbl.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_stdp.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_stsc.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_stsd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_stsz.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_stz2.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_text.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_tfhd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_tkhd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_treftype.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_trun.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_tx3g.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_udta.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_url.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_urn.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_uuid.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_video.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= atom_vmhd.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= cmeta.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= descriptors.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= exception.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= isma.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= log.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4atom.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4container.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4descriptor.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4file.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4file_io.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4info.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4property.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4track.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= mp4util.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= ocidescriptors.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= odcommands.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= qosqualifiers.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= rtphint.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= text.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= typebmff.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= CoverArtBox.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= Tags.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= generic.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= type.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= ColorParameterBox.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= PictureAspectRatioBox.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= coding.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= File.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= FileSystem.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= option.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= error.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= time.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= File_posix.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= FileSystem_posix.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= random_posix.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= process_posix.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= time_posix.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= Database.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= Timecode.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= TrackModifier.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= Utility.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= crc.cpp
[armeabi-v7a] Compile++ thumb: mp4v2 <= other.cpp
[armeabi-v7a] SharedLibrary : libmp4v2.so
[armeabi-v7a] Install : libmp4v2.so => libs/armeabi-v7a/libmp4v2.so
全类型So文件下载
编译了这么久,传上来给大家共享一下都觉得不好意思,因为ubuntu确实太难捣鼓了,为了编译这东西,又是装LINUX系统,又是学习.mk文件里面属性的作用,确实麻烦。
下载地址:https://download.csdn.net/download/chezi008/10412717