2

I know this question may be possible duplicate of many others questions but there is no good answer nor a good tutorial available for it

I want to use ffmpeg in my project I am using android ndk7 on windows don't have a clue what ffmpeg code to download,compile tutorial available is for UBUNTU nothing much for windows

I would really appreciate a really good answer.

Mycoola
  • 1,135
  • 1
  • 8
  • 29
Aashish Bhatnagar
  • 2,595
  • 2
  • 22
  • 37

2 Answers2

1

I was never able to build FFMPEG for Android under Windows but successfully did so under Ubuntu (after having some hard time though).

I used Oracle VM Virtual Box freeware to emulate Ubuntu machine under Windows.

I then built FFMPEG using the scripts from bambuser http://bambuser.com/opensource.

I then moved the resulting directory into the windows under my project's jni folder and referred the libs from my Android.mk

FFMPEG_DIR := ffmpeg
ifeq ($(TARGET_ARCH_ABI), armeabi)
FFMPEG_DIR := $(FFMPEG_DIR)/armeabi
else 
ifeq ($(TARGET_ARCH_ABI), armeabi-v7a) 
FFMPEG_DIR := $(FFMPEG_DIR)/armeabi-v7a
endif 
endif 

include $(CLEAR_VARS) 
LOCAL_MODULE := libavcodec
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE := libavcore
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE := libavdevice
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE := libavfilter
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE := libavformat
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE := libavutil
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)

include $(CLEAR_VARS) 
LOCAL_MODULE := libswscale
LOCAL_SRC_FILES := $(FFMPEG_DIR)/lib/$(LOCAL_MODULE).a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)/include
include $(PREBUILT_STATIC_LIBRARY)
Alexander Kulyakhtin
  • 47,782
  • 38
  • 107
  • 158
  • as I got your answer I should use ubuntu to compile ffmpeg http://bambuser.com/opensource. script using method specified here http://www.roman10.net/how-to-build-ffmpeg-for-android/ and then use it??? – Aashish Bhatnagar Apr 30 '12 at 12:07
  • roman10's method didn't work for me. I've just used the build.sh script they on bambuser site have in their open-source distribution (take the latest version) – Alexander Kulyakhtin Apr 30 '12 at 13:09
  • thanks alot for your efforts but since I don't know anything about it I am having a hard time understanding you I have installed ubuntu and downloaded bambuser code what should I do next shall I download ndk7 or ndk 5?? and how should I build the script in bambuser – Aashish Bhatnagar Apr 30 '12 at 14:00
  • ok I run build.sh it created a directory with one subfolder which contains two text files – Aashish Bhatnagar Apr 30 '12 at 14:17
  • There's a README file in the distribution. First run extract.sh then build. I don't rememeber everything by now but it builds pretty well – Alexander Kulyakhtin Apr 30 '12 at 14:21
  • thanks a lot for your help I am posting another question may be you can help me out there will post a link – Aashish Bhatnagar May 01 '12 at 08:02
  • http://stackoverflow.com/questions/10395136/create-a-video-file-from-images-using-ffmpeg – Aashish Bhatnagar May 01 '12 at 08:08
0

You can use this as build_android.sh i tested it and it worked with me

#!/bin/bash
NDK=D:/android/ndk/android-ndk-r10d
SYSROOT=$NDK/platforms/android-8/arch-arm/
TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/windows
function build_one
{
./configure \
--prefix=$PREFIX \
--disable-shared \
--enable-static \
--disable-doc \
--disable-ffmpeg \
--disable-ffplay \
--disable-ffprobe \
--disable-ffserver \
--disable-avdevice \
--disable-doc \
--disable-symver \
--cross-prefix=$TOOLCHAIN/bin/arm-linux-androideabi- \
--target-os=linux \
--arch=arm \
--enable-cross-compile \
--sysroot=$SYSROOT \
--extra-cflags="-Os -fpic $ADDI_CFLAGS" \
--extra-ldflags="$ADDI_LDFLAGS" \
$ADDITIONAL_CONFIGURE_FLAG
make clean
make
make install
}
CPU=arm
PREFIX=$(pwd)/android/$CPU
ADDI_CFLAGS="-marm"
build_one

you need also to run this commands :

dos2unix build_android.sh
chmod +x build_android.sh
./build_android.sh

Use this Tutorial as reference

Mycoola
  • 1,135
  • 1
  • 8
  • 29