2. 2
The Problem
There are many FFMPEG for Android
Scripts. Most of them doesn’t work duo to:
Frequent changes in FFMPEG Code
Changes in Android Tool chain
3. 3
Compilation instructions
Download the latest NDK 32bit version
there are problems when compiling on
NDK-64bit
Install the NDK on $Home/ (or change the
NDK address in the script)
Make sure you have root access to change
and create in the new directories there
might be a need to chmod 777 some of the
new directories manually
4. 4
Run the bottom script on this page saving it to
ffmpeg4android.sh push it to device sdcard and
chmod it to run enabled (described below). It is
recommended to unmark the git clone line of the
FFMPEG
From the bin directory push the ffmpeg to the /data
folder on the phone: adb push fmpeg /data/ffmpeg
Change ffmpeg permissions to run permissions
using: adb shell, cd /data, chmod 775 ffmpeg
Test ffmpeg on an Android local media file
5. 5
Instructions
1) Download the latest NDK 32bit version there are
problems when compiling on NDK-64bit
2) Install it on $Home/ (or change the script below)
3) Make sure you have root access to change and create
in the new directories there might be a need to chmod 777
some of the new directories manually
4) Run the script below by saving it to ffmpeg4android.sh
push it to device sdcard and chmod it to run enabled
(described below)
5) From the bin directory push the ffmpeg to the /data
folder on the phone: adb push fmpeg /data/ffmpeg
6) Change ffmpeg permissions to run permissions using:
adb shell, cd /data, chmod 775 ffmpeg
7) run ffmpeg on a local file
6. 6
Script
#!/bin/bash
echo ""
echo " ********** FFmpeg Android Build ********** "
echo ""
NDK=$HOME/android-ndk-r8d
PREBUILT=$NDK/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86
PLATFORM=$NDK/platforms/android-14/arch-arm
PREFIX=$HOME/FFmpeg.Binaries.Android
FFMPEG_BASE=$HOME/FFmpeg.Build
if [ -d "$FFMPEG_BASE" ]; then
rm -v -r -f $FFMPEG_BASE
fi
if [ -d "$PREFIX" ]; then
rm -v -r -f $PREFIX
fi
mkdir $FFMPEG_BASE
mkdir $PREFIX
# x264 Installation
echo ""
echo " ********** libx264 Installation ********** "
echo ""
cd $FFMPEG_BASE
git clone --depth 1 git://git.videolan.org/x264
cd $FFMPEG_BASE/x264
./configure --prefix=$PREFIX
--enable-static
--enable-pic
--disable-asm
--disable-cli
--host=arm-linux
--cross-prefix=$PREBUILT/bin/arm-linux-androideabi-
--sysroot=$PLATFORM
make
sudo make install
sudo ldconfig