android编译ffmpeg+x264+faac
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
免费下载资源
·
1. 在x264的源码目录下创建b1.sh,内容如下:
2. 在ffmepg的父目录下创建b1.sh,内容如下:并创建目录elib,并
把上面生成的lib264.a 拷贝到该目录下
到此为止so文件已经编译完毕:
下面编译jni的so文件;
上面so方式弄出来的,还是两个文件,在实际的java中,要限价在libffmpeg.so,然后在加载myffmp; 反序后会报告少依赖包, 但是按照该顺序还是加载失败;
然后按照下面的写法,可以生成单个so文件,且可以调试;
makefile 脚本: 注意-lgcc 应该放在最后,否则找到__aeabi_idiv等方法;
一步到位的ffmpeg+x264 for android 的编译;
1. 建立目录android,其下放置解压的ffmpeg和x264源码目录;建立install 目录,和make目录;
2. 在make中创建build.sh; 注意此处用的是相对目录,所以只能在make目录下运行;
点击(此处)折叠或打开
- export NDK=/opt/google/android/android-ndk-r8e
- export VERSION=4.4.3
- export PREBUILT=$NDK/toolchains/arm-linux-androideabi-$VERSION/prebuilt
- export PLATFORM=$NDK/platforms/android-8/arch-arm
- ./configure --enable-static \
- --enable-shared \
- --enable-pic \
- --disable-asm \
- --disable-cli \
- --host=arm-linux \
- --cross-prefix=$PREBUILT/linux-x86_64/bin/arm-linux-androideabi- \
- --sysroot=$PLATFORM
点击(此处)折叠或打开
- #!/bin/bash
- export VERSION=4.4.3
- export NDK=/opt/google/android/android-ndk-r8e
- export PREBUILT=$NDK/toolchains/arm-linux-androideabi-$VERSION/prebuilt/linux-x86_64
- export PLATFORM=$NDK/platforms/android-9/arch-arm
- export FFMPEG_ROOT=/home/test/code/ffmpeg-1.1.5
- export X264_ROOT=/home/test/code/x264_and #上面的x264的源码目录
- export ELIB="$FFMPEG_ROOT/elib"
- function build_one
- {
- $FFMPEG_ROOT/configure --target-os=linux \
- --enable-cross-compile \
- --enable-runtime-cpudetect \
- --disable-asm \
- --arch=arm \
- --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
- --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
- --disable-stripping \
- --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
- --sysroot=$PLATFORM \
- --enable-nonfree \
- --enable-version3 \
- --disable-everything \
- --enable-gpl \
- --disable-doc \
- --enable-avresample \
- --enable-demuxer=rtsp \
- --enable-muxer=rtsp \
- --disable-ffplay \
- --disable-ffserver \
- --enable-ffmpeg \
- --disable-ffprobe \
- --enable-libx264 \
- --enable-encoder=libx264 \
- --enable-decoder=h264 \
- --enable-protocol=rtp \
- --enable-hwaccels \
- --enable-zlib \
- --disable-devices \
- --disable-avdevice \
- --extra-cflags="-I$X264_ROOT -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
- --extra-ldflags="-L$ELIB"
- make -j4
- }
- build_one
- $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o
- $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$ELIB -soname libffmpeg.so -shared -nostdlib -z noexecstack -Bsymbolic --whole-archive --no-undefined -o libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/$VERSION/libgcc.a
下面编译jni的so文件;
点击(此处)折叠或打开
- LOCAL_PATH := $(call my-dir)
-
- include $(CLEAR_VARS)
- MY_PATH := /home/wanjm/code/binary #上面的so文件的目录
- LOCAL_MODULE := ffmpeg
- LOCAL_SRC_FILES := $(MY_PATH)/libffmpeg.so #仅支持一个文件;
- include $(PREBUILT_SHARED_LIBRARY)
-
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := myffmp
- LOCAL_SRC_FILES := VideoEncoder.c #jni的c文件;
- LOCAL_C_INCLUDES := /home/wanjm/code/ffmpeg-1.2.4
- LOCAL_LDLIBS := -llog -lm -lc -ldl -lz -lstdc++
- LOCAL_STATIC_LIBRARIES := libffmpeg #引用5处生成的so文件;
- include $(BUILD_SHARED_LIBRARY)
然后按照下面的写法,可以生成单个so文件,且可以调试;
点击(此处)折叠或打开
- LOCAL_PATH := $(call my-dir)
- MY_PATH :=/home/wanjm/code/binary/elib
-
- include $(CLEAR_VARS)
- #MY_PATH := /home/wanjm/code/binary
- #LOCAL_MODULE := ffmpeg
- #LOCAL_SRC_FILES := $(MY_PATH)/libffmpeg.so
- #include $(PREBUILT_SHARED_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := avcodec
- LOCAL_SRC_FILES := $(MY_PATH)/libavcodec.a
- include $(PREBUILT_STATIC_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := avformat
- LOCAL_SRC_FILES := $(MY_PATH)/libavformat.a
- include $(PREBUILT_STATIC_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := avutil
- LOCAL_SRC_FILES := $(MY_PATH)/libavutil.a
- include $(PREBUILT_STATIC_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := x264
- LOCAL_SRC_FILES := $(MY_PATH)/libx264.a
- include $(PREBUILT_STATIC_LIBRARY)
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := swscale
- LOCAL_SRC_FILES := $(MY_PATH)/libswscale.a
- include $(PREBUILT_STATIC_LIBRARY)
-
-
- include $(CLEAR_VARS)
- LOCAL_MODULE := myffmp
- LOCAL_SRC_FILES := VideoEncoder.c
- LOCAL_C_INCLUDES := /home/wanjm/code/ffmpeg-1.2.4
- LOCAL_LDLIBS := -llog -lm -lc -ldl -lz -lstdc++
- LOCAL_STATIC_LIBRARIES := libavformat libavutil libavcodec libswscale libavutil libx264
- include $(BUILD_SHARED_LIBRARY)
makefile 脚本: 注意-lgcc 应该放在最后,否则找到__aeabi_idiv等方法;
点击(此处)折叠或打开
- VERSION=4.8
- NDK_ROOT=/opt/google/android-ndk-r9b
- TOOLCHAINS_ROOT=$(NDK_ROOT)/toolchains/arm-linux-androideabi-$(VERSION)/prebuilt/linux-x86_64
- TOOLCHAINS_PREFIX=$(TOOLCHAINS_ROOT)/bin/arm-linux-androideabi
- TOOLCHAINS_INCLUDE=$(TOOLCHAINS_ROOT)/lib/gcc/arm-linux-androideabi/$(VERSION)/include-fixed
- SYSROOT=$(NDK_ROOT)/platforms/android-9/arch-arm
- PLATFORM_INCLUDE=$(SYSROOT)/usr/include
- PLATFORM_LIB=$(SYSROOT)/usr/lib
- FLAGS= -fpic -DANDROID
- #如果没有-lc,实际运行时会找不到gettimeofday;
- LDFLAGS=-shared -L$(PLATFORM_LIB) --no-undefined -lc -llog -lm -lc -ldl -lz #-nostdlib -ldl -lm -Bdynamic -lc -lstdc++
- #FLAGS="-I$(TOOLCHAINS_INCLUDE) -I$(PLATFORM_INCLUDE) " #-L$(PLATFORM_LIB) -nostdlib -lgcc -Bdynamic -lc"
- CC=$(TOOLCHAINS_PREFIX)-gcc --sysroot=$(SYSROOT)
- LD=$(TOOLCHAINS_PREFIX)-ld
- libtime.so: main.o
- $(LD) $(LDFLAGS) main.o -o libtime.so -L/home/wanjm/code/binary/elib -lavformat -lavutil -lavcodec -lswscale -lavutil -lx264 -L$(TOOLCHAINS_ROOT)/lib/gcc/arm-linux-androideabi/$(VERSION) -lgcc
- cp libtime.so ../libs/armeabi
- main.o: VideoEncoder.c
- $(CC) -c VideoEncoder.c -o main.o -I/home/wanjm/code/ffmpeg-1.2.4
- clean:
- rm -rf libtime.so
- rm main.o
一步到位的ffmpeg+x264 for android 的编译;
1. 建立目录android,其下放置解压的ffmpeg和x264源码目录;建立install 目录,和make目录;
2. 在make中创建build.sh; 注意此处用的是相对目录,所以只能在make目录下运行;
点击(此处)折叠或打开
- #!/bin/bash
- export VERSION=4.6
- export NDK=/opt/google/android-ndk-r9b
- export PREBUILT=$NDK/toolchains/arm-linux-androideabi-$VERSION/prebuilt/linux-x86_64
- export PLATFORM=$NDK/platforms/android-9/arch-arm
- export FFMPEG_ROOT=../ffmpeg-1.2.4
- export X264_ROOT=../x264 #上面的x264的源码目录
- export PREFIX=../install
- export ELIB="$PREFIX/lib"
- export FAAC_ROOT=../faac-1.28
- function build_x264
- {
- cd $X264_ROOT
- pwd
- ./configure --enable-static \
- --prefix=$PREFIX \
- --enable-shared \
- --enable-pic \
- --disable-asm \
- --disable-cli \
- --host=arm-linux \
- --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
- --sysroot=$PLATFORM
- make
- cp libx264.a $ELIB
- cd -
- }
- function build_faac
- {
- cd $FAAC_ROOT
- pwd
- CFLAGS="-fpic -DANDROID -fpic -mthumb-interwork -ffunction-sections -funwind-tables -fstack-protector -fno-short-enums -D__ARM_ARCH_5__ -D__ARM_ARCH_5T__ -D__ARM_ARCH_5E__ -D__ARM_ARCH_5TE__ -Wno-psabi -march=armv5te -mtune=xscale -msoft-float -mthumb -Os -fomit-frame-pointer -fno-strict-aliasing -finline-limit=64 -DANDROID -Wa,--noexecstack -MMD -MP "
- #FLAGS="--host=arm-androideabi-linux --enable-static --disable-shared --prefix=$HOME --enable-armv5e "
- CROSS_COMPILE=$PREBUILT/bin/arm-linux-androideabi-
- export CPPFLAGS="$CFLAGS"
- export CFLAGS="$CFLAGS"
- export CXXFLAGS="$CFLAGS"
- export CXX="${CROSS_COMPILE}g++ --sysroot=${PLATFORM}"
- export LDFLAGS="$LDFLAGS"
- export CC="${CROSS_COMPILE}gcc --sysroot=${PLATFORM}"
- export NM="${CROSS_COMPILE}nm"
- export STRIP="${CROSS_COMPILE}strip"
- export RANLIB="${CROSS_COMPILE}ranlib"
- export AR="${CROSS_COMPILE}ar"
- ./configure --program-prefix=$PREFIX \
- --host=arm-linux
- make
- cp ./libfaac/.libs/libfaac.a $ELIB
- cd -
- }
- function build_one
- {
- $FFMPEG_ROOT/configure --target-os=linux \
- --prefix=$PREFIX \
- --enable-cross-compile \
- --enable-runtime-cpudetect \
- --disable-asm \
- --arch=arm \
- --cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
- --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
- --disable-stripping \
- --nm=$PREBUILT/bin/arm-linux-androideabi-nm \
- --sysroot=$PLATFORM \
- --enable-nonfree \
- --enable-version3 \
- --enable-gpl \
- --disable-doc \
- --enable-avresample \
- --enable-demuxer=rtsp \
- --enable-muxer=rtsp \
- --disable-ffplay \
- --disable-ffserver \
- --enable-ffmpeg \
- --disable-ffprobe \
- --enable-libx264 \
- --enable-libfaac --enable-nonfree \
- --enable-encoder=libx264 \
- --enable-decoder=h264 \
- --enable-protocol=rtp \
- --enable-encoder=libfaac \
- --enable-decoder=aac \
- --enable-hwaccels \
- --enable-zlib \
- --disable-devices \
- --disable-avdevice \
- --extra-cflags="-I$X264_ROOT -I$FAAC_ROOT/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a" \
- --extra-ldflags="-L$ELIB"
- make -j4
- make install
- }
- mkdir -p $ELIB
- build_faac
- build_x264
- build_one
GitHub 加速计划 / li / linux-dash
10.39 K
1.2 K
下载
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 4 年前
5def40a3
Add host customization support for the NodeJS version 4 年前
更多推荐
已为社区贡献5条内容
所有评论(0)