public
Last active

Building FFMPEG+libx264 for Android NDK

  • Download Gist
Android.mk
Makefile
1 2 3 4 5 6 7 8 9
LOCAL_PATH := $(call my-dir)
 
include $(CLEAR_VARS)
LOCAL_MODULE := videokit
FFMPEG_LIBS := $(shell find ffmpeg -name '*.a')
LOCAL_CFLAGS += -Iffmpeg
LOCAL_LDLIBS += -llog $(FFMPEG_LIBS)
LOCAL_SRC_FILES := jni_interface.c
include $(BUILD_SHARED_LIBRARY)
gistfile1.eclass
Gentoo Eclass
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
# There are a few ways to build this using the NDK. Using version r5b here as it introduces
# better support for standalone building, so we can use FFMPEG's configure and make and a
# minimal Android.mk to pull it all together
 
# should point to where your NDK is
NDK=~/android-ndk-r5b
 
# get ffmpeg
git clone git://git.ffmpeg.org/ffmpeg.git
cd ffmpeg
 
# build a standalone toolchain - you could install this to somewhere more permanent
$NDK/build/tools/make-standalone-toolchain.sh --install-dir=/tmp/android/toolchain
export PATH=$PATH:$NDK:/tmp/android/toolchain/bin
 
./configure --enable-cross-compile \
--arch=arm5te \
--enable-armv5te \
--target-os=linux \
--disable-stripping \
--disable-neon \
--enable-version3 \
--disable-shared \
--enable-static \
--enable-gpl \
--enable-memalign-hack \
--cc=arm-linux-androideabi-gcc \
--ld=arm-linux-androideabi-ld \
--extra-cflags="-fPIC -DANDROID -D__thumb__ -mthumb" \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-network \
--disable-mpegaudio-hp \
--disable-avdevice \
--enable-zlib
 
# make, and wait
make
jni_interface.c
C
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
 
#include <android/log.h>
#include <jni.h>
 
int init()
{
av_register_all();
__android_log_write(ANDROID_LOG_ERROR, "VideoKit", "Better implement some JNI methods!")
}
 
/* Compile your Java class with native methods then run javah on it to generate a header file */

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.