FFMPEG on android

3,673 views

Published on

How to compile FFMPEG for Android

Published in: Technology, Education
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
3,673
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
30
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

FFMPEG on android

  1. 1. 1 Yossi Cohen FFMPEG for Android
  2. 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. 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. 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. 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. 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
  7. 7. 7 Script-2 #FFmpeg Installation echo "" echo " ********** FFmpeg (Android) Installation ********** " echo "" cd $FFMPEG_BASE git clone --depth 1 git://source.ffmpeg.org/ffmpeg cd $FFMPEG_BASE/ffmpeg ./configure --target-os=linux --prefix=$PREFIX --enable-cross-compile --enable-runtime-cpudetect --disable-asm  --arch=arm --cc=$PREBUILT/bin/arm-linux-androideabi-gcc --cross-prefix=$PREBUILT/bin/arm-linux-androideabi- --disable-stripping --nm=$PREBUILT/bin/arm-linux-androideabi-nm --sysroot=$PLATFORM --enable-nonfree --enable-version3 --enable-gpl --disable-doc --enable-avresample --enable-demuxer=rtsp --enable-muxer=rtsp --disable-ffserver --disable-ffprobe
  8. 8. 8 Script 3--enable-ffmpeg --enable-ffplay --enable-libx264 --enable-encoder=libx264 --enable-decoder=h264 --enable-protocol=rtp --enable-hwaccels --enable-zlib --extra-cflags="-I$PREFIX/include -fPIC -DANDROID -D__thumb__ -mthumb -Wfatal-errors -Wno-deprecated -mfloat-abi=softfp -mfpu=vfpv3-d16 -marm -march=armv7-a"  --extra-ldflags="-L$PREFIX/lib" make -j4 install $PREBUILT/bin/arm-linux-androideabi-ar d libavcodec/libavcodec.a inverse.o $PREBUILT/bin/arm-linux-androideabi-ld -rpath-link=$PLATFORM/usr/lib -L$PLATFORM/usr/lib -L$PREFIX/lib  -soname libffmpeg.so -shared -nostdlib  - z,noexecstack -Bsymbolic --whole-archive --no-undefined -o $PREFIX/libffmpeg.so libavcodec/libavcodec.a libavfilter/libavfilter.a libavresample/libavresample.a libavformat/libavformat.a libavutil/libavutil.a libswscale/libswscale.a -lc -lm -lz -ldl -llog -lx264 --warn-once --dynamic-linker=/system/bin/linker $PREBUILT/lib/gcc/arm-linux-androideabi/4.4.3/libgcc.a # rm -v -r -f $FFMPEG_BASE clear echo "" echo "FFmpeg Android Build Successful..." echo "" ls -l -R $PREFIX
  9. 9. 9 Thank you!  Video Expert  Lectures on Video / Android / VoIP  Android Native Developer More About me: Yossi CohenYossi Cohen yossicohen19@gmail.comyossicohen19@gmail.com http://www.mobilevideotech.com  +972-545-313092+972-545-313092
  10. 10. 10 Resources Script source http://stackoverflow.com/questions/14751069 /how-to-stream-to-ffserver-from-android

×