FFMEPG 平台移植,接口简化和外部模块接入 (五)ffmpe

2018-05-30  本文已影响0人  car_eye

前面我们用在ubuntu下编译了android的动态库,但实际开发中,我们可能需要在android 这类开发工具中开发基于太ffmpeg的视频应用。在android studio 中编译需要注意以下几点

1. As ndk 对应的sdk不能大于编译ffmpeg本身编译的NDK中使用的SDK。可以在application.mk中指定:

APP_PLATFORM := android-XX 如果XX小于了ffmpeg编译的SDK,则会报如log2无法链接这类问题

2.  编译库的链接顺序必须要对,一般有这样规律,主库要在依赖库前面链接。对于需要filter的系统来说一般的链接顺序如下:avformat avfilter avcodec x264 avresample swresample freetype libpng avutil swscale postproc

下面给出编译的具体make文件

#APP_ABI := armeabi armeabi-v7a x86

ifeq ($(APP_ABI), x86)

LIB_NAME_PLUS := x86

else

LIB_NAME_PLUS := armeabi

endif

LOCAL_PATH:= $(call my-dir)

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true

include $(CLEAR_VARS)

LOCAL_MODULE:= avcodec-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES:= prebuilt/$(LIB_NAME_PLUS)/libavcodec.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := swresample-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libswresample.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := avresample-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libavresample.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := x264-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libx264.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := swscale-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libswscale.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE :=  freetype-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libfreetype.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE:= avfilter-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES:= prebuilt/$(LIB_NAME_PLUS)/libavfilter.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE:= avformat-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES:= prebuilt/$(LIB_NAME_PLUS)/libavformat.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE :=  avutil-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libavutil.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE :=  postproc-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libpostproc.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

LOCAL_MODULE := libpng17-prebuilt-$(LIB_NAME_PLUS)

LOCAL_SRC_FILES := prebuilt/$(LIB_NAME_PLUS)/libpng17.a

include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS)

ifeq ($(APP_ABI), x86)

TARGET_ARCH:=x86

TARGET_ARCH_ABI:=x86

else

LOCAL_ARM_MODE := arm

endif

LOCAL_ALLOW_UNDEFINED_SYMBOLS := true 

LOCAL_MODULE := libffmpegjni

LOCAL_SRC_FILES := CarEyeJni.c CarEyeEncoderAPI.cpp FFVideoFilter.cpp CarEyeOSDAPI.cpp CarEyeMPEGAPI.cpp CarEyeDecoderAPI.cpp

LOCAL_LDLIBS := -L$(SYSROOT)/usr/lib -llog -lz -lm 

LOCAL_STATIC_LIBRARIES := avformat-prebuilt-$(LIB_NAME_PLUS) \

avfilter-prebuilt-$(LIB_NAME_PLUS) \

avcodec-prebuilt-$(LIB_NAME_PLUS) \

x264-prebuilt-$(LIB_NAME_PLUS) \

avresample-prebuilt-$(LIB_NAME_PLUS) \

swresample-prebuilt-$(LIB_NAME_PLUS) \

freetype-prebuilt-$(LIB_NAME_PLUS) \

libpng17-prebuilt-$(LIB_NAME_PLUS) \

avutil-prebuilt-$(LIB_NAME_PLUS) \

swscale-prebuilt-$(LIB_NAME_PLUS) \

postproc-prebuilt-$(LIB_NAME_PLUS) 

LOCAL_C_INCLUDES += -L$(SYSROOT)/usr/include

LOCAL_C_INCLUDES += $(LOCAL_PATH)/include

ifeq ($(APP_ABI), x86)

LOCAL_CFLAGS := -DUSE_X86_CONFIG

else

LOCAL_CFLAGS := -DUSE_ARM_CONFIG

endif

include $(BUILD_SHARED_LIBRARY)

相关代码请参考car-eye 开源网站和github为准

car-eye开源官方网址:www.car-eye.cn  

car-eye 流媒体平台网址:www.liveoss.com   

car-eye 技术官方邮箱: support@car-eye.cn

car-eye技术交流QQ群: 590411159

CopyRight©  car-eye 开源团队 2018

下一篇:FFMEPG 平台移植,接口简化和外部模块接入 (六)ffmpeg android移植(ffmpeg android 下解码器)

上一篇下一篇

猜你喜欢

热点阅读