Android ffmpeg+librtmp+speex交叉編譯

一、記錄

Ubuntu 14 64位

ndk r10b

librtmp 2.4

speex 1.2rc2

ffmpeg 2.8.1


二、編譯

1、編譯librtmp

下載地址:http://rtmpdump.mplayerhq.hu/

Android.mk

# This is the Android makefile for librtmp
LOCAL_PATH:= $(call my-dir)

include $(CLEAR_VARS)

LOCAL_SRC_FILES := \
amf.c \
hashswf.c \
log.c \
parseurl.c \
rtmp.c

LOCAL_CFLAGS += -DNO_CRYPTO

LOCAL_MODULE := librtmp
LOCAL_MODULE_TAGS := optional

include $(BUILD_STATIC_LIBRARY)


Application.mk

# The ARMv7 is significanly faster due to the use of the hardware FPU
APP_ABI := armeabi-v7a
APP_MODULES := librtmp
APP_PLATFORM := android-14


2、編譯speex

下載地址:http://www.speex.org/downloads/

Android.mk

LOCAL_PATH := $(call my-dir)  
       
include $(CLEAR_VARS)  
       
LOCAL_MODULE := libspeex  
LOCAL_CFLAGS = -DFIXED_POINT -DUSE_KISS_FFT -DEXPORT="" -UHAVE_CONFIG_H  
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include  
       
LOCAL_SRC_FILES :=  \
    ./libspeex/bits.c \
    ./libspeex/cb_search.c \
    ./libspeex/exc_10_16_table.c \
    ./libspeex/exc_10_32_table.c \
    ./libspeex/exc_20_32_table.c \
    ./libspeex/exc_5_256_table.c \
    ./libspeex/exc_5_64_table.c \
    ./libspeex/exc_8_128_table.c \
    ./libspeex/filters.c \
    ./libspeex/gain_table.c \
    ./libspeex/gain_table_lbr.c \
    ./libspeex/hexc_10_32_table.c \
    ./libspeex/hexc_table.c \
    ./libspeex/high_lsp_tables.c \
    ./libspeex/kiss_fft.c \
    ./libspeex/kiss_fftr.c \
    ./libspeex/lpc.c \
    ./libspeex/lsp.c \
    ./libspeex/lsp_tables_nb.c \
    ./libspeex/ltp.c \
    ./libspeex/modes.c \
    ./libspeex/modes_wb.c \
    ./libspeex/nb_celp.c \
    ./libspeex/quant_lsp.c \
    ./libspeex/sb_celp.c \
    ./libspeex/smallft.c \
    ./libspeex/speex.c \
    ./libspeex/speex_callbacks.c \
    ./libspeex/speex_header.c \
    ./libspeex/stereo.c \
    ./libspeex/testenc.c \
    ./libspeex/testenc_uwb.c \
    ./libspeex/testenc_wb.c \
    ./libspeex/vbr.c \
    ./libspeex/vorbis_psy.c \
    ./libspeex/vq.c \
    ./libspeex/window.c
       
include $(BUILD_STATIC_LIBRARY)  


Application.mk

APP_ABI := armeabi-v7a 
APP_MODULES := libspeex
APP_PLATFORM := android-14


3、編譯ffmpeg  

下載命令:git clone git://source.ffmpeg.org/ffmpeg.git ffmpeg

(1)修改configure

#enabled librtmp           && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
enabled librtmp && require librtmp librtmp/rtmp.h RTMP_Socket -lrtmp

#enabled libspeex          && require_pkg_config speex speex/speex.h speex_decoder_init -lspeex
enabled libspeex && require libspeex speex/speex.h speex_decoder_init -lspeex


(2)腳本

#!/bin/bash


LOCAL_PATH=`pwd`
export WORK_HOME=/home/governor
export NDK=$WORK_HOME/android-ndk-r10b
export PLATFORM=$NDK/platforms/android-8/arch-arm
export PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.6/prebuilt/linux-x86_64
export PREFIX=$LOCAL_PATH/build

pushd ffmpeg

./configure \
--arch=arm \
--target-os=linux \
--prefix=$PREFIX \
--enable-version3 \
--enable-gpl \
--disable-debug \
--enable-small \
--enable-memalign-hack \
--enable-pthreads \
--enable-asm \
--disable-shared \
--enable-static \
--enable-network \
\
--disable-muxers \
--disable-encoders \
--disable-programs \
--disable-doc \
--disable-postproc \
--disable-filters \
\
--disable-demuxer=avi \
--disable-demuxer=ogg \
\
--disable-decoders \
--enable-decoder=dvvideo \
--enable-decoder=rawvideo \
--enable-decoder=smvjpeg \
--enable-decoder=mlp \
--enable-decoder=flv \
--enable-decoder=h264 \
--enable-decoder=h264_crystalhd \
--enable-decoder=h264_mmal \
--enable-decoder=h264_qsv \
--enable-decoder=h264_vda \
--enable-decoder=h264_vdpau \
--enable-decoder=aac \
--enable-decoder=aac_fixed \
--enable-decoder=aac_latm \
--enable-decoder=adpcm_thp_le \
--enable-decoder=adpcm_vima \
--enable-decoder=adpcm_xa \
--enable-decoder=adpcm_yamaha \
--enable-decoder=libspeex \
\
--disable-protocols \
--enable-protocol=hls \
--enable-protocol=http \
--enable-protocol=librtmp \
--enable-protocol=rtmp \
--enable-protocol=rtp \
--enable-protocol=udp \
--enable-protocol=tcp \
\
--enable-librtmp \
--enable-libspeex \
--cc=$PREBUILT/bin/arm-linux-androideabi-gcc \
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi- \
--nm=$PREBUILT/bin/arm-linux-androideabi-nm \
--sysroot=$PLATFORM \
--extra-cflags="-I$PREFIX/include -O3 -fpic -march=armv7-a -mtune=cortex-a8 -mfloat-abi=softfp -mfpu=neon -DANDROID" \
--extra-ldflags="-L$PREFIX/lib"

make -j4 install

popd
popd


三、問題總結

1、Android工程添加librtmp.a後,提示各種unreference RTMP_XXXX

解決:最早使用gcc編譯librtmp,直接在rtmpdump/librtmp下make,nm查看所有unreference的函數都有,最後是更改了ffmpeg編譯腳本,configure報錯“librtmp not found”,查看了config.log,發現提示ld path/to/librtmp.a incompatible ...,最終改爲ndk編譯librtmp;

注:speex通librtmp



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章