Created
February 15, 2011 20:57
-
-
Save halfninja/828227 to your computer and use it in GitHub Desktop.
Building FFMPEG+libx264 for Android NDK
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment