Script and Instructions for building FFmpeg for Android

Related tags

Media FFmpeg-Android
Overview

FFmpeg-Android

Herein lies scripts and instructions for compiling FFmpeg for Android with RTMP support. Much thanks to Chris Ballinger and Liu Feipeng.

Instructions

Optional RTMP support dependencies

If you'd like to build FFmpeg with --enable-librtmp, first download and build OpenSSL and librtmp:

OpenSSL

  1. The GuardianProject have a great project that makes building as simple as invoking ndk-build.

librtmp

  1. Clone RTMPDump, and copy build_librtmp_for_android.sh into the ./librtmp subdirectory.

     $ git clone git://git.ffmpeg.org/rtmpdump
     $ cp /path/to/build_librtmp_for_android.sh ./rtmpdump/librtmp
     $ ./rtmpdump/librtmp/build_librtmp_for_android.sh
    
  2. Modify the header variables in build_librtmp_for_android.sh as appropriate:

     #build_librtmp_for_android.sh
     NDK=/path/to/your/android-ndk-r9c
     SYSROOT=$NDK/platforms/android-19/arch-arm/
     TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64
     OPENSSL_DIR=/path/to/your/openssl-android/
     ...
    

Building FFmpeg

  1. Download the FFmpeg source you desire (This process is tested with 2.1.3)

  2. Modify configure ever so slightly to conform to the Android NDK build system:

     # ffmpegX.X.X/configure
     ...
     # Replace the following lines:
     
     #SLIBNAME_WITH_MAJOR='$(SLIBNAME).$(LIBMAJOR)'
     #LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
     #SLIB_INSTALL_NAME='$(SLIBNAME_WITH_VERSION)'
     #SLIB_INSTALL_LINKS='$(SLIBNAME_WITH_MAJOR) $(SLIBNAME)'
     
     # With: 
     
     SLIBNAME_WITH_MAJOR='$(SLIBPREF)$(FULLNAME)-$(LIBMAJOR)$(SLIBSUF)'
     LIB_INSTALL_EXTRA_CMD='$$(RANLIB) "$(LIBDIR)/$(LIBNAME)"'
     SLIB_INSTALL_NAME='$(SLIBNAME_WITH_MAJOR)'
     SLIB_INSTALL_LINKS='$(SLIBNAME)'
    

If building with RTMP support: Also modify the following line of configure:

    # Replace this:
    enabled librtmp    && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
    # With this:
    enabled librtmp    && require librtmp librtmp/rtmp.h RTMP_Socket -L/path/to/rtmpdump/librtmp/android/arm/lib -lrtmp
  1. Copy build_ffmpeg_for_android.sh or build_ffmpeg_with_librtmp_for_android.sh to ffmpegX.X.X/ and run! a. Make sure the script is executable:

    	$ sudo chmod +x build_ffmpeg_for_android.sh    
    

    b. Make any desired changes to build_ffmpeg_for_android.sh per your build target. c. Run!

    	$ ./build_ffmpeg_for_android.sh	
    	# or to build with debugging symbols:
    	$ ./build_ffmpeg_debug_for_android.sh
    

The result will be a collection of static libraries and headers at ffmpegX.X.X/android/

Note on Building with Debugging Symbols

We had to pass the -gdwarf-2 flag to gcc to properly generate debugging symbols for the ffmpeg libraries. A lot was going on, and perhaps instead something yet unexplained happened at a sub-atomic level.

Comments
  • avcodec_find_encoder returns null

    avcodec_find_encoder returns null

    I tried recompiling ffmpeg with rtmp support with this https://github.com/OnlyInAmerica/FFmpeg-Android/blob/master/build_ffmpeg_with_librtmp_for_android.sh

    However this line avcodec_find_encoder(CODEC_ID_H264); always returns me null. i useFFMpegwrapper.c from openwatch, but this avformat_write_header gives me invalid header

    I also tried to print all codecs through the below code(ensured avcodec_register_all() is called before), but it returned empty?? while(codec = av_codec_next(codec)) { LOGI("Registered codec name %s" , codec->name); }

    Any help on this..

    opened by marudhupandiyang 0
  • arm-linux-androideabi-gcc is unable to create an executable file. C compiler test failed.

    arm-linux-androideabi-gcc is unable to create an executable file. C compiler test failed.

    i am having error :

    agile@agilepc-123:~/Desktop/NDK_FFMPEG/ffmpeg$ ./build_ffmpeg_for_android.sh

    /home/agile/Desktop/NDK_FFMPEG/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc is unable to create an executable file. C compiler test failed.

    If you think configure made a mistake, make sure you are using the latest version from Git. If the latest version fails, report the problem to the [email protected] mailing list or IRC #ffmpeg on irc.freenode.net. Include the log file "config.log" produced by configure as this will help solve the problem. Makefile:2: config.mak: No such file or directory Makefile:59: /common.mak: No such file or directory Makefile:100: /libavutil/Makefile: No such file or directory Makefile:100: /library.mak: No such file or directory Makefile:102: /doc/Makefile: No such file or directory Makefile:185: /tests/Makefile: No such file or directory make: *** No rule to make target /tests/Makefile'. Stop. Makefile:2: config.mak: No such file or directory Makefile:59: /common.mak: No such file or directory Makefile:100: /libavutil/Makefile: No such file or directory Makefile:100: /library.mak: No such file or directory Makefile:102: /doc/Makefile: No such file or directory Makefile:185: /tests/Makefile: No such file or directory make: *** No rule to make target/tests/Makefile'. Stop. Makefile:2: config.mak: No such file or directory Makefile:59: /common.mak: No such file or directory Makefile:100: /libavutil/Makefile: No such file or directory Makefile:100: /library.mak: No such file or directory Makefile:102: /doc/Makefile: No such file or directory Makefile:185: /tests/Makefile: No such file or directory make: *** No rule to make target `/tests/Makefile'. Stop.

    Please help me to solve this error.

    opened by ddpatel2606 8
  • cannot find -ldl collect2: error: ld returned 1 exit status

    cannot find -ldl collect2: error: ld returned 1 exit status

    i also posted this problem in this link http://stackoverflow.com/questions/22653241/comple-librtmp-for-android-error-cannot-find-ldl-collect2-error-ld-returned

    opened by molavy 0
  • cannot open crtbegin_so.o: No such file cannot open crtbegin_so.o: No such file cannot find -ldl

    cannot open crtbegin_so.o: No such file cannot open crtbegin_so.o: No such file cannot find -ldl

    i have problem on compile librtmp this is my ... file:

    !/bin/bash

    NDK=/home/user/loc_app/android-ndk-r9

    /home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm

    SYSROOT=$NDK/platforms/android-18/arch-arm

    platforms/android-19/arch-arm/

    TOOLCHAIN=$NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

    /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64

    OPENSSL_DIR=/home/user/libs/openssl-android-master/

    Note: Change the above variables for your system.

    function build_one { set -e make clean ln -s ${SYSROOT}usr/lib/crtbegin_so.o ln -s ${SYSROOT}usr/lib/crtend_so.o export XLDFLAGS="$ADDI_LDFLAGS -L${OPENSSL_DIR}libs/armeabi -L${SYSROOT}usr/lib " export CROSS_COMPILE=$TOOLCHAIN/bin/arm-linux-androideabi- export XCFLAGS="${ADDI_CFLAGS} -I${OPENSSL_DIR}include -isysroot ${SYSROOT}" export INC="-I${SYSROOT}" make prefix="${PREFIX}" OPT= install } CPU=arm PREFIX=$(pwd)/android/$CPU ADDI_CFLAGS="-marm" build_one

    return this error: librtmp]$ ./build_librtmp_for_android.sh rm -f .o *.a *.so *.so.1 librtmp.pc /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -Wall -marm -I/home/user/libs/openssl-android-master/include -isysroot /home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -I/home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -DRTMPDUMP_VERSION="v2.4" -DUSE_OPENSSL -fPIC -c -o rtmp.o rtmp.c rtmp.c: In function 'RTMP_ReadPacket': rtmp.c:3575:7: warning: variable 'didAlloc' set but not used [-Wunused-but-set-variable] int didAlloc = FALSE; ^ /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -Wall -marm -I/home/user/libs/openssl-android-master/include -isysroot /home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -I/home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -DRTMPDUMP_VERSION="v2.4" -DUSE_OPENSSL -fPIC -c -o log.o log.c /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -Wall -marm -I/home/user/libs/openssl-android-master/include -isysroot /home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -I/home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -DRTMPDUMP_VERSION="v2.4" -DUSE_OPENSSL -fPIC -c -o amf.o amf.c In file included from amf.c:33:0: bytes.h:74:2: warning: #warning "Float word order not defined, assuming the same as byte order!" [-Wcpp] #warning "Float word order not defined, assuming the same as byte order!" ^ /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -Wall -marm -I/home/user/libs/openssl-android-master/include -isysroot /home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -I/home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -DRTMPDUMP_VERSION="v2.4" -DUSE_OPENSSL -fPIC -c -o hashswf.o hashswf.c /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -Wall -marm -I/home/user/libs/openssl-android-master/include -isysroot /home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -I/home/user/loc_app/android-ndk-r9/platforms/android-18/arch-arm -DRTMPDUMP_VERSION="v2.4" -DUSE_OPENSSL -fPIC -c -o parseurl.o parseurl.c /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar rs librtmp.a rtmp.o log.o amf.o hashswf.o parseurl.o /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-ar: creating librtmp.a sed -e "s;@prefix@;"/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm";" -e "s;@libdir@;"/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/lib;"
    -e "s;@VERSION@;v2.4;"
    -e "s;@CRYPTO_REQ@;libssl,libcrypto;"
    -e "s;@PUBLIC_LIBS@;;"
    -e "s;@PRIVATE_LIBS@;;" librtmp.pc.in > librtmp.pc mkdir -p "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/include/librtmp "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/lib/pkgconfig "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/man/man3 "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/lib cp amf.h http.h log.h rtmp.h "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/include/librtmp cp librtmp.a "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/lib cp librtmp.pc "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/lib/pkgconfig cp librtmp.3 "/home/user/libs/ffmpeg_android/rtmpdump/librtmp/android/arm"/man/man3 /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/arm-linux-androideabi-gcc -shared -Wl,-soname,librtmp.so.1 -L/home/user/libs/openssl-android-master/libs/armeabi -L/home/user/loc_app/android-ndk-r9/platforms/android-18/arch-armusr/lib -o librtmp.so.1 rtmp.o log.o amf.o hashswf.o parseurl.o -lssl -lcrypto -lz /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtbegin_so.o: No such file or directory /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot open crtend_so.o: No such file or directory /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lssl /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lcrypto /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lz /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -lc /home/user/loc_app/android-ndk-r9/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: error: cannot find -ldl collect2: error: ld returned 1 exit status make: *
    * [librtmp.so.1] Error 1

    so when i try use ./build_ffmpeg_with_librtmp_for_android.sh return ERROR: librtmp not found error

    os : fedora 19 ,64bit

    opened by molavy 2
  • librtmp

    librtmp

    Hello, after compiling how do we pas the complex rtmp urls? example : rtmp://host.com/live playpath=123 swfUrl=http://host.com/123.swf live=1 pageUrl=http://website.tv timeout=10 token=token do we send as AVOptions to Vitamio or just like a normal link. thanks

    opened by wmsgeek 5
Owner
David Brodsky
A little nonsense now and then is relished by the wisest men
David Brodsky
script(s) to build ffmpeg for android, including support for RTMP (and OpenSSL)

android-ffmpeg-with-rtmp This repository contains script(s) to build ffmpeg for android with RTMP (and OpenSSL) support. Instructions Install the Andr

cine.io 234 Dec 28, 2022
a system for building custom ffmpeg binaries for Android

This is a new android-ffmpeg project since it seems there were so many different ways of doing it, it was confusing. So here is my clean, easily chan

Guardian Project 967 Nov 12, 2022
[] FFmpeg build for android random architectures with example jni

AndroidFFmpegLibrary This project aims to create working library providing playing video files in android via ffmpeg libraries. With some effort and N

AppUnite Sp. z o.o. Spk. 1k Mar 1, 2021
Android Java wrapper around ffmpeg command line binary

FFMPEG Library for Android This project is a Java wrapper around an ffmpeg command line binary for use in Android applications. It depends on the andr

Guardian Project 555 Dec 5, 2022
Android/iOS video player based on FFmpeg n3.4, with MediaCodec, VideoToolbox support.

ijkplayer Platform Build Status Android iOS Video player based on ffplay Download Android: Gradle # required allprojects { repositories {

bilibili 28.9k May 26, 2021
Convert audio files inside your Android app easily. Supported formats: AAC, MP3, M4A, WMA, WAV and FLAC.

AndroidAudioConverter Convert audio files inside your Android app easily. This is a wrapper of FFmpeg-Android-Java lib. Supported formats: AAC MP3 M4A

Adriel Café 1.3k Jan 5, 2023
A mod of the Twitch Android Mobile App adding BetterTTV and FrankerFaceZ emotes

A mod of the Twitch Android Mobile App adding BetterTTV and FrankerFaceZ emotes

null 377 Jan 2, 2023
A Java API to read, write and create MP4 files

Build status: Current central released version 1.x branch: Current central released version 2.x branch: Java MP4 Parser A Java API to read, write and

Sebastian Annies 2.4k Apr 2, 2021
AndroidPhotoFilters aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image media.

PhotoFiltersSDK PhotoFiltersSDK aims to provide fast, powerful and flexible image processing instrument for creating awesome effects on any image medi

Zomato 2.5k Dec 30, 2022
Convert video to GIF. Simple and fast.

Convert video to GIF. Simple and fast.

tasy5kg 24 Nov 26, 2022
[] Easily integrate Camera features into your Android app

Deprecated CameraView is deprecated. No more development will be taking place. Use Jetpack CameraX instead. CameraView This is not an official Google

Google 4.8k Dec 29, 2022
A solution for streaming H.264, H.263, AMR, AAC using RTP on Android

Introduction What it does libstreaming is an API that allows you, with only a few lines of code, to stream the camera and/or microphone of an android

Simon 3.3k Dec 30, 2022
MJPEG video streaming on Android

ipcam-view Android MJPEG video streaming made simple! A wrapper library around the well known SimpleMjpegView and android-camera-axis projects. If you

null 359 Jan 6, 2023
android video player base on ijkplayer

GiraffePlayer NOTE:this project is no longer update please using improved GiraffePlayer2 ,for flutter please visit GPlayer out of the box android vide

tom 683 Nov 14, 2022
Android MoveNet single human pose estimation by ncnn

Android MoveNet single human pose estimation by ncnn

FeiGeChuanShu 93 Dec 31, 2022
FFmpeg compiled for Android. Execute FFmpeg commands with ease in your Android app.

FFMPEG video operations FFmpeg compiled for Android. Execute FFmpeg commands with ease in your Android app. Getting Started This project is provide in

Simform Solutions 277 Jan 2, 2023
Mirror of https://git.ffmpeg.org/ffmpeg.git

FFmpeg README FFmpeg is a collection of libraries and tools to process multimedia content such as audio, video, subtitles and related metadata. Librar

null 33.5k Jan 9, 2023
script(s) to build ffmpeg for android, including support for RTMP (and OpenSSL)

android-ffmpeg-with-rtmp This repository contains script(s) to build ffmpeg for android with RTMP (and OpenSSL) support. Instructions Install the Andr

cine.io 234 Dec 28, 2022
:closed_umbrella: An easy way to implement modern permission instructions popup.

Needs An easy way to implement modern permission instructions popup. Needs can be fully customized and showing with animations. Download Gradle Add be

Jaewoong Eum 609 Dec 8, 2022