Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ffmpeg with rtmpdump #463

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions ffmpeg/cppbuild.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ if [[ -z "$PLATFORM" ]]; then
fi

DISABLE="--disable-w32threads --disable-iconv --disable-opencl --disable-sdl --disable-bzlib --disable-lzma"
ENABLE="--enable-pthreads --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-openssl --enable-libopenh264 --enable-libx264 --enable-libx265 --enable-libvpx"
ENABLE="--enable-pthreads --enable-shared --enable-gpl --enable-version3 --enable-nonfree --enable-runtime-cpudetect --enable-zlib --enable-libmp3lame --enable-libspeex --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-openssl --enable-libopenh264 --enable-libx264 --enable-libx265 --enable-libvpx --enable-librtmp"

# minimal configuration to support MPEG-4 streams with H.264 and AAC as well as Motion JPEG
# DISABLE="--disable-w32threads --disable-iconv --disable-libxcb --disable-opencl --disable-sdl --disable-bzlib --disable-lzma --disable-everything"
Expand All @@ -18,7 +18,7 @@ ZLIB=zlib-1.2.11
LAME=lame-3.99.5
SPEEX=speex-1.2.0
OPENCORE_AMR=opencore-amr-0.1.5
OPENSSL=openssl-1.1.0f
OPENSSL=openssl-1.0.2l
OPENH264_VERSION=1.7.0
X265=x265_2.4
VPX_VERSION=v1.6.1
Expand All @@ -28,7 +28,7 @@ download http://zlib.net/$ZLIB.tar.gz $ZLIB.tar.gz
download http://downloads.sourceforge.net/project/lame/lame/3.99/$LAME.tar.gz $LAME.tar.gz
download http://downloads.xiph.org/releases/speex/$SPEEX.tar.gz $SPEEX.tar.gz
download http://sourceforge.net/projects/opencore-amr/files/opencore-amr/$OPENCORE_AMR.tar.gz/download $OPENCORE_AMR.tar.gz
download https://www.openssl.org/source/$OPENSSL.tar.gz $OPENSSL.tar.gz
# download https://www.openssl.org/source/$OPENSSL.tar.gz $OPENSSL.tar.gz
download https://github.com/cisco/openh264/archive/v$OPENH264_VERSION.tar.gz openh264-$OPENH264_VERSION.tar.gz
download ftp://ftp.videolan.org/pub/videolan/x264/snapshots/last_stable_x264.tar.bz2 last_stable_x264.tar.bz2
download https://ftp.videolan.org/pub/videolan/x265/$X265.tar.gz $X265.tar.gz
Expand All @@ -39,12 +39,13 @@ download http://ffmpeg.org/releases/ffmpeg-$FFMPEG_VERSION.tar.bz2 ffmpeg-$FFMPE
mkdir -p $PLATFORM
cd $PLATFORM
INSTALL_PATH=`pwd`
git clone git://git.ffmpeg.org/rtmpdump
echo "Decompressing archives..."
tar --totals -xzf ../$ZLIB.tar.gz
tar --totals -xzf ../$LAME.tar.gz
tar --totals -xzf ../$SPEEX.tar.gz
tar --totals -xzf ../$OPENCORE_AMR.tar.gz
tar --totals -xzf ../$OPENSSL.tar.gz
# tar --totals -xzf ../$OPENSSL.tar.gz
tar --totals -xzf ../openh264-$OPENH264_VERSION.tar.gz
tar --totals -xjf ../last_stable_x264.tar.bz2
tar --totals -xzf ../$X265.tar.gz
Expand All @@ -66,7 +67,27 @@ case $PLATFORM in
export CXXFLAGS="$CFLAGS"
export LDFLAGS="-nostdlib -Wl,--fix-cortex-a8 -z text"
export LIBS="-lgcc -ldl -lz -lm -lc"
cd $ZLIB

cp ${ANDROID_ROOT}usr/lib/crtbegin_so.o rtmpdump/
cp ${ANDROID_ROOT}usr/lib/crtend_so.o rtmpdump/
cp ${ANDROID_ROOT}usr/lib/crtbegin_so.o rtmpdump/librtmp/
cp ${ANDROID_ROOT}usr/lib/crtend_so.o rtmpdump/librtmp/

cp ${ANDROID_ROOT}usr/lib/crtbegin_dynamic.o rtmpdump/
cp ${ANDROID_ROOT}usr/lib/crtend_android.o rtmpdump/
cp ${ANDROID_ROOT}usr/lib/crtbegin_dynamic.o rtmpdump/librtmp/
cp ${ANDROID_ROOT}usr/lib/crtend_android.o rtmpdump/librtmp/

git clone https://github.com/openssl/openssl.git $OPENSSL
cd $OPENSSL
git checkout OpenSSL_1_0_2-stable
cd ..

cd ffmpeg-$FFMPEG_VERSION
export INSTALL_PATH_LIB="$INSTALL_PATH/lib"
patch -Np1 < ../../../ffmpeg-librtmp.patch

cd ../$ZLIB
./configure --prefix=$INSTALL_PATH --static --uname=arm-linux
make -j $MAKEJ
make install
Expand All @@ -86,10 +107,17 @@ case $PLATFORM in
make -j $MAKEJ
make install
cd ../$OPENSSL
./Configure --prefix=$INSTALL_PATH android-armeabi $CFLAGS no-shared
./Configure --prefix=$INSTALL_PATH android-armv7 $CFLAGS no-shared
ANDROID_DEV="$ANDROID_ROOT/usr" make # fails with -j > 1
make install_sw
cd ../openh264-$OPENH264_VERSION
make install
cd ../rtmpdump/librtmp
OPENSSL_DIR="$INSTALL_PATH/$OPENSSL/"
export XLDFLAGS="-L${OPENSSL_DIR} -L${ANDROID_ROOT}usr/lib "
export CROSS_COMPILE="${ANDROID_BIN}-"
export XCFLAGS="${CFLAGS} -marm -I${OPENSSL_DIR}include -isysroot ${ANDROID_ROOT}"
export INC="-I${ANDROID_ROOT}"
make prefix=\"${INSTALL_PATH}\" OPT= install
cd ../../openh264-$OPENH264_VERSION
LDFLAGS= make -j $MAKEJ PREFIX=$INSTALL_PATH OS=android ARCH=arm USE_ASM=No NDKROOT="$ANDROID_NDK" TARGET="$ANDROID_ROOT" libraries install-static
cd ../$X264
./configure --prefix=$INSTALL_PATH --enable-static --enable-pic --disable-cli --cross-prefix="$ANDROID_BIN-" --sysroot="$ANDROID_ROOT" --host=arm-linux --extra-cflags="$CFLAGS" --extra-ldflags="$LDFLAGS $LIBS"
Expand All @@ -106,7 +134,8 @@ case $PLATFORM in
make install
cd ../ffmpeg-$FFMPEG_VERSION
patch -Np1 < ../../../ffmpeg-$FFMPEG_VERSION-android.patch
./configure --prefix=.. $DISABLE $ENABLE --enable-cross-compile --cross-prefix="$ANDROID_BIN-" --ranlib="$ANDROID_BIN-ranlib" --sysroot="$ANDROID_ROOT" --target-os=linux --arch=arm --extra-cflags="-I../include/ $CFLAGS" --extra-ldflags="$ANDROID_ROOT/usr/lib/crtbegin_so.o -L../lib/ -L$ANDROID_CPP/libs/armeabi/ $LDFLAGS" --extra-libs="-lgnustl_static $LIBS" --disable-symver --disable-programs
LIBRTMP_DIR="$INSTALL_PATH/rtmpdump/librtmp/"
./configure --prefix=.. $DISABLE $ENABLE --enable-cross-compile --cross-prefix="$ANDROID_BIN-" --ranlib="$ANDROID_BIN-ranlib" --sysroot="$ANDROID_ROOT" --target-os=linux --arch=arm --extra-cflags="-I../include/ $CFLAGS -I${LIBRTMP_DIR}android/arm/include -L${LIBRTMP_DIR}android/arm/lib -lrtmp" --extra-ldflags="$ANDROID_ROOT/usr/lib/crtbegin_so.o -L../lib/ -L$ANDROID_CPP/libs/armeabi/ $LDFLAGS -L${LIBRTMP_DIR}android/arm/lib -lrtmp" --extra-libs="-lgnustl_static $LIBS" --disable-symver --disable-programs
make -j $MAKEJ
make install
;;
Expand Down
26 changes: 6 additions & 20 deletions ffmpeg/ffmpeg-3.3.2-android.patch
Original file line number Diff line number Diff line change
Expand Up @@ -28,28 +28,14 @@ diff -ruN ffmpeg-3.3.2/configure ffmpeg-3.3.2-android/configure
{ check_cpp_condition x265.h "X265_BUILD >= 68" ||
die "ERROR: libx265 version must be >= 68."; }
enabled libxavs && require libxavs "stdint.h xavs.h" xavs_encoder_encode -lxavs
@@ -5916,10 +5916,10 @@
check_header OMX_Core.h ; } ||
die "ERROR: OpenMAX IL headers not found"; }
enabled openssl && { use_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl ||
- use_pkg_config openssl openssl/ssl.h SSL_library_init ||
- check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto ||
- check_lib openssl/ssl.h SSL_library_init -lssl32 -leay32 ||
- check_lib openssl/ssl.h SSL_library_init -lssl -lcrypto -lws2_32 -lgdi32 ||
+ use_pkg_config openssl openssl/ssl.h OPENSSL_init_ssl ||
+ check_lib openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto ||
+ check_lib openssl/ssl.h OPENSSL_init_ssl -lssl32 -leay32 ||
+ check_lib openssl/ssl.h OPENSSL_init_ssl -lssl -lcrypto -lws2_32 -lgdi32 ||
die "ERROR: openssl not found"; }
enabled qtkit_indev && { check_header_objcc QTKit/QTKit.h || disable qtkit_indev; }


diff -ruN ffmpeg-3.3.2/library.mak ffmpeg-3.3.2-android/library.mak
--- ffmpeg-3.3.2/library.mak 2017-06-07 11:03:56.000000000 +0900
+++ ffmpeg-3.3.2-android/library.mak 2017-06-23 20:10:54.718543524 +0900
@@ -34,16 +34,13 @@
$(SUBDIR)lib$(NAME).ver: $(SUBDIR)lib$(NAME).v $(OBJS)
$$(M)sed 's/MAJOR/$(lib$(NAME)_VERSION_MAJOR)/' $$< | $(VERSION_SCRIPT_POSTPROCESS_CMD) > $$@

-$(SUBDIR)$(SLIBNAME): $(SUBDIR)$(SLIBNAME_WITH_MAJOR)
- $(Q)cd ./$(SUBDIR) && $(LN_S) $(SLIBNAME_WITH_MAJOR) $(SLIBNAME)
-
Expand All @@ -58,15 +44,15 @@ diff -ruN ffmpeg-3.3.2/library.mak ffmpeg-3.3.2-android/library.mak
$(SLIB_CREATE_DEF_CMD)
$$(LD) $(SHFLAGS) $(LDFLAGS) $(LDLIBFLAGS) $$(LD_O) $$(filter %.o,$$^) $(FFEXTRALIBS)
$(SLIB_EXTRA_CMD)

ifdef SUBDIR
-$(SUBDIR)$(SLIBNAME_WITH_MAJOR): $(DEP_LIBS)
+$(SUBDIR)$(SLIBNAME): $(DEP_LIBS)
endif

clean::
@@ -56,9 +53,8 @@

install-lib$(NAME)-shared: $(SUBDIR)$(SLIBNAME)
$(Q)mkdir -p "$(SHLIBDIR)"
- $$(INSTALL) -m 755 $$< "$(SHLIBDIR)/$(SLIB_INSTALL_NAME)"
Expand All @@ -79,7 +65,7 @@ diff -ruN ffmpeg-3.3.2/library.mak ffmpeg-3.3.2-android/library.mak
$(if $(SLIB_INSTALL_EXTRA_LIB),$$(INSTALL) -m 644 $(SLIB_INSTALL_EXTRA_LIB:%=$(SUBDIR)%) "$(LIBDIR)")
@@ -77,9 +73,7 @@
$$(INSTALL) -m 644 $$^ "$(PKGCONFIGDIR)"

uninstall-libs::
- -$(RM) "$(SHLIBDIR)/$(SLIBNAME_WITH_MAJOR)" \
- "$(SHLIBDIR)/$(SLIBNAME)" \
Expand Down
13 changes: 13 additions & 0 deletions ffmpeg/ffmpeg-librtmp.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/configure b/configure
index 72ffaea..0eec3d8 100644
--- a/configure
+++ b/configure
@@ -5730,7 +5730,7 @@ enabled libopenjpeg && { { check_lib2 openjpeg-2.1/openjpeg.h opj_version
enabled libopenmpt && require_pkg_config "libopenmpt >= 0.2.6557" libopenmpt/libopenmpt.h openmpt_module_create
enabled libopus && require_pkg_config opus opus_multistream.h opus_multistream_decoder_create
enabled libpulse && require_pkg_config libpulse pulse/pulseaudio.h pa_context_new
-enabled librtmp && require_pkg_config librtmp librtmp/rtmp.h RTMP_Socket
+enabled librtmp && require librtmp librtmp/rtmp.h RTMP_Socket -L${INSTALL_PATH_LIB} -lrtmp
enabled librubberband && require_pkg_config "rubberband >= 1.8.1" rubberband/rubberband-c.h rubberband_new
enabled libschroedinger && require_pkg_config schroedinger-1.0 schroedinger/schro.h schro_init
enabled libshine && require_pkg_config shine shine/layer3.h shine_encode_buffer