Mac下面编译Android FFmpeg3.2.4
2017-07-26 20:10
387 查看
需要搞直播,打算使用ffmpeg进行推流,于是在Mac下进行了编译FFMmpeg。
1、下载ffmpeg源码,我下载的是ffmpeg-3.2.4;
2、配置好build_android.sh编译安卓脚本,脚本如下,
我这里选择的CPU的架构是arm,有其他需要可自行添加;
3、为脚本赋予可执行权限;
4、执行脚本,经过一番编译等待之后,我这边编译了几遍大约在十五分钟编译完成;
5、打开AS,我的测试版本是AS 2.3版本,所以使用的是CMakelist.txt来进行编译的,把刚才编译好的源码复制到项目的libs下面;
6、编译CMakelist.txt文件,完整的如下;
7、编译运行,成功,明天就可以开撸直播了,哈哈,附上下载链接。
1、下载ffmpeg源码,我下载的是ffmpeg-3.2.4;
2、配置好build_android.sh编译安卓脚本,脚本如下,
cd /Users/xxxx/Documents/DevTool/ffmpeg-3.2.4 NDK=/Users/xxxx/Documents/DevTool/AndroidSDK/android-sdk-macosx/ndk-bundle SYSROOT=$NDK/platforms/android-9/arch-arm/ TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 function build_one{ ./configure \ --prefix=$PREFIX \ --enable-shared \ --disable-static \ --disable-doc \ --disable-ffmpeg \ --disable-ffplay \ --disable-ffprobe \ --disable-ffserver \ --disable-avdevice \ --disable-doc \ --disable-symver \ --cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \ --target-os=linux \ --arch=arm \ --enable-cross-compile \ --sysroot=$SYSROOT \ --extra-cflags="-Os -fpic $ADDI_CFLAGS" \ --extra-ldflags="$ADDI_LDFLAGS" \ $ADDITIONAL_CONFIGURE_FLAG make clean make make install } CPU=arm PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" build_one
我这里选择的CPU的架构是arm,有其他需要可自行添加;
3、为脚本赋予可执行权限;
chmod -R 775 build_android.sh
4、执行脚本,经过一番编译等待之后,我这边编译了几遍大约在十五分钟编译完成;
5、打开AS,我的测试版本是AS 2.3版本,所以使用的是CMakelist.txt来进行编译的,把刚才编译好的源码复制到项目的libs下面;
6、编译CMakelist.txt文件,完整的如下;
//For more information about using CMake with Android Studio, read the //documentation: https://d.android.com/studio/projects/add-native-code.html //Sets the minimum version of CMake required to build the native library. cmake_minimum_required(VERSION 3.4.1) find_library( # Sets the name of the path variable. log-lib # Specifies the name of the NDK library that # you want CMake to locate. log ) set(distribution_DIR ${CMAKE_SOURCE_DIR}/../../../../libs) add_library( avutil-55 SHARED IMPORTED ) set_target_properties( avutil-55 PROPERTIES IMPORTED_LOCATION ../../../../libs/arm/libavutil-55.so ) add_library( swresample-2 SHARED IMPORTED ) set_target_properties( swresample-2 PROPERTIES IMPORTED_LOCATION ../../../../libs/arm/libswresample-2.so ) add_library( avcodec-57 SHARED IMPORTED ) set_target_properties( avcodec-57 PROPERTIES IMPORTED_LOCATION ../../../../libs/arm/libavcodec-57.so ) add_library( avfilter-6 SHARED IMPORTED) set_target_properties( avfilter-6 PROPERTIES IMPORTED_LOCATION ../../../../libs/arm/libavfilter-6.so ) add_library( swscale-4 SHARED IMPORTED) set_target_properties( swscale-4 PROPERTIES IMPORTED_LOCATION ../../../../libs/arm/libswscale-4.so ) add_library( avformat-57 SHARED IMPORTED) set_target_properties( avformat-57 PROPERTIES IMPORTED_LOCATION ../../../../libs/arm/libavformat-57.so ) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11") add_library( native-lib SHARED src/main/cpp/native-lib.cpp ) include_directories(libs/include) //target_include_directories(native-lib PRIVATE libs/include) target_link_libraries(native-lib ${avutil-55} ${swresample-2} ${avcodec-57} ${avfilter-6} ${swscale-4} ${avformat-57} ${log-lib} )
7、编译运行,成功,明天就可以开撸直播了,哈哈,附上下载链接。
相关文章推荐
- MAC系统下利用NDK编译可供Android使用的FFmpeg(3.2.4)库
- mac 平台下编译android版本 ffmpeg+h264
- 终于在android下面完成了ffmpeg最新版的编译,弱弱的记录
- mac下 ffmpeg 编译到android平台(支持 frei0r)
- FFmpeg-3.3.1移植到Android平台(Mac编译)
- 【史上最傻瓜的】mac下编译FFmpeg-Android
- MAC系统下编译FFmpeg-Android (从编译到移植Androidstudio成功)(一)
- mac下编译FFmpeg-Android
- mac下编译FFmpeg-Android
- Mac下为Android Studio编译Ffmpeg(二)Android Studio部分
- 【史上最傻瓜的】mac下编译FFmpeg-Android
- Mac环境下编译Android平台的ffmpeg
- Android 编译FFmpeg(Mac环境)
- mac下 ffmpeg 编译到android平台
- mac 安装cordova,编译android下面的app
- mac编译Android版本ffmpeg的x86_64架构库
- 终于在android下面完成了ffmpeg最新版的编译
- 编译havlenapetr同学的Android FFMpeg项目
- 编译ffmpeg到android
- windows下编译最新版ffmpeg3.3-android,并通过CMake方式移植到Android studio2.3中