Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Building FFMPEG+libx264 for Android NDK
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := videokit
FFMPEG_LIBS := $(shell find ffmpeg -name '*.a')
LOCAL_CFLAGS += -Iffmpeg
LOCAL_SRC_FILES := jni_interface.c
# 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 to pull it all together
# should point to where your NDK is
# get ffmpeg
git clone git://
cd ffmpeg
# build a standalone toolchain - you could install this to somewhere more permanent
$NDK/build/tools/ --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 \
# make, and wait
#include "libavformat/avformat.h"
#include "libavdevice/avdevice.h"
#include "libswscale/swscale.h"
#include <android/log.h>
#include <jni.h>
int init()
__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 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment