From d6018ff5aa490311af0c32bcbf89c4eacb84ad0c Mon Sep 17 00:00:00 2001 From: qwu16 Date: Mon, 21 Feb 2022 17:15:56 +0800 Subject: [PATCH 1/5] Add SRT caller support --- scripts/installCommonDeps.sh | 38 ++++- scripts/installDeps.sh | 11 ++ scripts/installDepsUnattended.sh | 9 ++ scripts/pack.js | 1 + scripts/release/install_ffmpeg.sh | 60 +++++++- .../streaming/compile_ffmpeg_with_libsrt.sh | 141 ++++++++++++++++++ source/agent/streaming/dist.json | 1 + 7 files changed, 257 insertions(+), 4 deletions(-) create mode 100755 source/agent/streaming/compile_ffmpeg_with_libsrt.sh diff --git a/scripts/installCommonDeps.sh b/scripts/installCommonDeps.sh index 22b701a9f..23eb54afe 100644 --- a/scripts/installCommonDeps.sh +++ b/scripts/installCommonDeps.sh @@ -20,6 +20,35 @@ check_proxy(){ fi } +install_srt(){ + local VERSION="1.4.1" + local SRC="v${VERSION}.tar.gz" + local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" + local SRC_DIR="srt-${VERSION}" + + local LIST_LIBS=`ls ${PREFIX_DIR}/lib/libsrt.* 2>/dev/null` + [ "$INCR_INSTALL" = true ] && [[ ! -z $LIST_LIBS ]] && \ + echo "srt already installed." && return 0 + + if [ "$CHECK_INSTALL" = true ]; then + if [[ ! -z $LIST_LIBS ]]; then + echo "srt - Yes" + else + echo "srt - No" + fi + return 0 + fi + + mkdir -p ${LIB_DIR} + pushd ${LIB_DIR} + wget ${SRC_URL} + rm -fr ${SRC_DIR} + tar xf ${SRC} + pushd ${SRC_DIR} + ./configure --prefix=${PREFIX_DIR} + make && make install +} + install_fdkaac(){ local VERSION="0.1.6" local SRC="fdk-aac-${VERSION}.tar.gz" @@ -61,6 +90,7 @@ install_ffmpeg(){ local SRC="${DIR}.tar.bz2" local SRC_URL="http://ffmpeg.org/releases/${SRC}" local SRC_MD5SUM="9c2ca54e7f353a861e57525ff6da335b" + local SRT_OPTION=" " local LIST_LIBS=`ls ${PREFIX_DIR}/lib/libav* 2>/dev/null` [ "$INCR_INSTALL" = true ] && [[ ! -z $LIST_LIBS ]] && \ @@ -75,6 +105,10 @@ install_ffmpeg(){ return 0 fi + if [ "$ENABLE_SRT" = true ]; then + SRT_OPTION="--enable-libsrt" + fi + mkdir -p ${LIB_DIR} pushd ${LIB_DIR} [[ ! -s ${SRC} ]] && wget -c ${SRC_URL} @@ -87,8 +121,8 @@ install_ffmpeg(){ tar xf ${SRC} pushd ${DIR} [[ "${DISABLE_NONFREE}" == "true" ]] && \ - PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype || \ - PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libfdk-aac --enable-nonfree && \ + PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype ${SRT_OPTION} || \ + PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libfdk-aac --enable-nonfree ${SRT_OPTION} && \ make -j4 -s V=0 && make install popd popd diff --git a/scripts/installDeps.sh b/scripts/installDeps.sh index 509bffd75..46a408698 100755 --- a/scripts/installDeps.sh +++ b/scripts/installDeps.sh @@ -15,6 +15,7 @@ INCR_INSTALL=false CHECK_INSTALL=false ONLY_INSTALL="" ENABLE_WEBTRANSPORT=false +ENABLE_SRT=false SUDO="" if [[ $EUID -ne 0 ]]; then @@ -29,6 +30,7 @@ print_help(){ echo " --check check whether dependencies are installed" echo " --incremental skip dependencies which are already installed" echo " --enable-webtransport install dependencies with webtransport" + echo " --enable-srt install dependencies with srt" echo " --with-nonfree-libs install nonfree dependencies" echo " --cleanup remove intermediate files after installation" echo " --only [dep] only install specified dependency [dep]" @@ -58,6 +60,9 @@ parse_arguments(){ "--enable-webtransport") ENABLE_WEBTRANSPORT=true ;; + "--enable-srt") + ENABLE_SRT=true + ;; "--help") print_help ;; @@ -146,6 +151,12 @@ fi pause "Installing Node.js ... [press Enter]" install_node +if [ "$ENABLE_SRT" = "true" ]; then + [ "$CHECK_INSTALL" != true ] && \ + pause "Installing libsrt library.... [press Enter]" + install_srt +fi + if [ "$DISABLE_NONFREE" = "true" ]; then [ "$CHECK_INSTALL" != true ] && \ pause "Nonfree libraries disabled: aac transcoding unavailable. [press Enter]" diff --git a/scripts/installDepsUnattended.sh b/scripts/installDepsUnattended.sh index 6d59b4176..cf26c551c 100755 --- a/scripts/installDepsUnattended.sh +++ b/scripts/installDepsUnattended.sh @@ -15,6 +15,7 @@ NO_INTERNAL=false INCR_INSTALL=false CHECK_INSTALL=false ENABLE_WEBTRANSPORT=false +ENABLE_SRT=false SUDO="" if [ "$GITHUB_ACTIONS" == "true" ]; then @@ -33,6 +34,7 @@ print_help(){ echo " --check check whether dependencies are installed" echo " --incremental skip dependencies which are already installed" echo " --with-nonfree-libs install nonfree dependencies" + echo " --enable-srt install dependencies with srt" echo " --cleanup remove intermediate files after installation" echo " --help print help of this script" echo @@ -60,6 +62,9 @@ parse_arguments(){ "--check") CHECK_INSTALL=true ;; + "--enable-srt") + ENABLE_SRT=true + ;; esac shift done @@ -105,6 +110,10 @@ fi if [ "$NIGHTLY" != "true" ] && [ "$GITHUB_ACTIONS" != "true" ]; then + if [ "$ENABLE_SRT" = "true" ]; then + install_srt + fi + if [ "$DISABLE_NONFREE" = "true" ]; then install_mediadeps else diff --git a/scripts/pack.js b/scripts/pack.js index 1b3c90250..9df7af2a2 100755 --- a/scripts/pack.js +++ b/scripts/pack.js @@ -468,6 +468,7 @@ function isLibAllowed(libSrc) { 'libowt_web_transport', ]; if (!options['archive'] || options['with-ffmpeg']) { + whiteList.push('libsrt'); whiteList.push('libav'); whiteList.push('libsw'); if (osType.includes('centos') || (osType.includes('ubuntu') && osType.includes('20.04'))) { diff --git a/scripts/release/install_ffmpeg.sh b/scripts/release/install_ffmpeg.sh index b3c3cca05..d2e284b78 100755 --- a/scripts/release/install_ffmpeg.sh +++ b/scripts/release/install_ffmpeg.sh @@ -6,10 +6,31 @@ this=`dirname "$0"` this=`cd "$this"; pwd` SUDO="" +ENABLE_SRT=false if [[ $EUID -ne 0 ]]; then SUDO="sudo -E" fi +echo "Streaming agent install ffmpeg" +echo $1 + +parse_arguments(){ + while [ "$1" != "" ]; do + case $1 in + "--enable-srt") + echo "Enable SRT" + ENABLE_SRT=true + ;; + "--cleanup") + CLEANUP=true + ;; + esac + shift + done +} + + + detect_OS() { lsb_release >/dev/null 2>/dev/null if [ $? = 0 ] @@ -57,16 +78,40 @@ install_build_deps() { then echo -e "\x1b[32mInstalling dependent components and libraries via yum...\x1b[0m" ${SUDO} yum install pkg-config make gcc gcc-c++ nasm yasm freetype-devel -y + if [ "$ENABLE_SRT" = "true" ]; then + ${SUDO} yum install tcl openssl-devel cmake automake -y + fi elif [[ "$OS" =~ .*ubuntu.* ]] then echo -e "\x1b[32mInstalling dependent components and libraries via apt-get...\x1b[0m" ${SUDO} apt-get update ${SUDO} apt-get install pkg-config make gcc g++ nasm yasm libfreetype6-dev -y + if [ "$ENABLE_SRT" = "true" ]; then + ${SUDO} apt-get install tcl cmake libssl-dev build-essential -y + fi else echo -e "\x1b[32mUnsupported platform...\x1b[0m" fi } +install_srt(){ + local VERSION="1.4.1" + local SRC="v${VERSION}.tar.gz" + local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" + local SRC_DIR="srt-${VERSION}" + local PREFIX_DIR="${this}/ffmpeg-install" + mkdir -p ${LIB_DIR} + pushd ${LIB_DIR} + wget ${SRC_URL} + rm -fr ${SRC_DIR} + tar xf ${SRC} + pushd ${SRC_DIR} + ./configure --prefix=${PREFIX_DIR} + make && make install + popd + popd +} + install_ffmpeg(){ local VERSION="4.1.3" local DIR="ffmpeg-${VERSION}" @@ -88,8 +133,13 @@ install_ffmpeg(){ rm -fr ${DIR} tar xf ${SRC} pushd ${DIR} >/dev/null - CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ - --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype + if [ "$ENABLE_SRT" = "true" ]; then + PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ + --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt + else + CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ + --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype + fi make -j4 -s V=0 && make install popd popd @@ -98,8 +148,14 @@ install_ffmpeg(){ cp -P ${PREFIX_DIR}/lib/*.so ${this}/lib/ } +parse_arguments $* + echo "Install building dependencies..." install_build_deps +if [ "$ENABLE_SRT" = "true" ]; then +install_srt +fi + echo "Install ffmpeg..." install_ffmpeg diff --git a/source/agent/streaming/compile_ffmpeg_with_libsrt.sh b/source/agent/streaming/compile_ffmpeg_with_libsrt.sh new file mode 100755 index 000000000..893e48c07 --- /dev/null +++ b/source/agent/streaming/compile_ffmpeg_with_libsrt.sh @@ -0,0 +1,141 @@ +##!/usr/bin/env bash +# Copyright (C) <2019> Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +this=$(pwd) + +DOWNLOAD_DIR="${this}/ffmpeg_libsrt_src" +TARGET_DIR="${this}/ffmpeg_libsrt_lib" +SUDO="" +if [[ $EUID -ne 0 ]]; then + SUDO="sudo -E" +fi + +detect_OS() { + lsb_release >/dev/null 2>/dev/null + if [ $? = 0 ] + then + lsb_release -ds | sed 's/^\"//g;s/\"$//g' + # a bunch of fallbacks if no lsb_release is available + # first trying /etc/os-release which is provided by systemd + elif [ -f /etc/os-release ] + then + source /etc/os-release + if [ -n "${PRETTY_NAME}" ] + then + printf "${PRETTY_NAME}\n" + else + printf "${NAME}" + [[ -n "${VERSION}" ]] && printf " ${VERSION}" + printf "\n" + fi + # now looking at distro-specific files + elif [ -f /etc/arch-release ] + then + printf "Arch Linux\n" + elif [ -f /etc/gentoo-release ] + then + cat /etc/gentoo-release + elif [ -f /etc/fedora-release ] + then + cat /etc/fedora-release + elif [ -f /etc/redhat-release ] + then + cat /etc/redhat-release + elif [ -f /etc/debian_version ] + then + printf "Debian GNU/Linux " ; cat /etc/debian_version + else + printf "Unknown\n" + fi +} + +install_build_deps() { + local OS=$(detect_OS | awk '{print tolower($0)}') + echo $OS + + if [[ "$OS" =~ .*centos.* ]] + then + echo -e "\x1b[32mInstalling dependent components and libraries via yum...\x1b[0m" + ${SUDO} yum install pkg-config make gcc gcc-c++ nasm yasm freetype-devel -y + elif [[ "$OS" =~ .*ubuntu.* ]] + then + echo -e "\x1b[32mInstalling dependent components and libraries via apt-get...\x1b[0m" + ${SUDO} apt-get update + ${SUDO} apt-get install pkg-config make gcc g++ nasm yasm libfreetype6-dev -y + else + echo -e "\x1b[32mUnsupported platform...\x1b[0m" + fi +} + +install_srt(){ + local VERSION="1.4.1" + local SRC="v${VERSION}.tar.gz" + local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" + local SRC_DIR="srt-${VERSION}" + local PREFIX_DIR="${this}/ffmpeg-install" + mkdir -p ${LIB_DIR} + pushd ${LIB_DIR} + wget ${SRC_URL} + rm -fr ${SRC_DIR} + tar xf ${SRC} + pushd ${SRC_DIR} + ./configure --prefix=${PREFIX_DIR} + make && make install + popd + popd +} + +install_ffmpeg(){ + local VERSION="4.1.3" + local DIR="ffmpeg-${VERSION}" + local SRC="${DIR}.tar.bz2" + local SRC_URL="http://ffmpeg.org/releases/${SRC}" + local SRC_MD5SUM="9985185a8de3678e5b55b1c63276f8b5" + + echo "Downloading ffmpeg-${VERSION}" + [[ ! -s ${SRC} ]] && wget -c ${SRC_URL} + if ! (echo "${SRC_MD5SUM} ${SRC}" | md5sum --check) ; then + echo "Downloaded file ${SRC} is corrupted." + rm -v ${SRC} + return 1 + fi + rm -fr ${DIR} + tar xf ${SRC} + + echo "Building ffmpeg-${VERSION}" + pushd ${DIR} + PKG_CONFIG_PATH=${DOWNLOAD_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${DOWNLOAD_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt && \ + make -j4 -s V=0 && make install + popd +} + +echo "This script will download and compile a libsrt enabled ffmpeg." +read -p "Continue to compile ffmpeg with libsrt? [No/yes]" yn +case $yn in + [Yy]* ) ;; + [Nn]* ) exit 0;; + * ) ;; +esac + +echo "Install building dependencies..." +install_build_deps + +[[ ! -d ${DOWNLOAD_DIR} ]] && mkdir ${DOWNLOAD_DIR}; + +pushd ${DOWNLOAD_DIR} +install_srt +install_ffmpeg +popd + +[[ ! -d ${TARGET_DIR} ]] && mkdir ${TARGET_DIR}; + +echo "Copy libs to ${TARGET_DIR}" +cp -P ${DOWNLOAD_DIR}/lib/*.so.* ${TARGET_DIR} +cp -P ${DOWNLOAD_DIR}/lib/*.so ${TARGET_DIR}/ + +echo "Compiling finish." +echo "Downloaded source dir: ${DOWNLOAD_DIR}" +echo "Compiled library dir: ${TARGET_DIR}" + diff --git a/source/agent/streaming/dist.json b/source/agent/streaming/dist.json index ee560cb99..1f4f25d05 100644 --- a/source/agent/streaming/dist.json +++ b/source/agent/streaming/dist.json @@ -6,6 +6,7 @@ "files": [ "agent.toml", "log4js_configuration.json", + "compile_ffmpeg_with_libsrt.sh", "install_deps.sh", "configLoader.js", "../index.js", From a6f6b49b0d85c16dbd8591f9e44f74003eba6808 Mon Sep 17 00:00:00 2001 From: qwu16 Date: Tue, 22 Feb 2022 10:26:23 +0800 Subject: [PATCH 2/5] Add SRT caller mode support by default --- scripts/installCentOSDeps.sh | 4 +- scripts/installCommonDeps.sh | 11 +- scripts/installDeps.sh | 11 -- scripts/installDepsUnattended.sh | 9 -- scripts/installUbuntuDeps.sh | 4 +- scripts/release/install_ffmpeg.sh | 31 +--- .../streaming/compile_ffmpeg_with_libsrt.sh | 141 ------------------ source/agent/streaming/dist.json | 1 - 8 files changed, 16 insertions(+), 196 deletions(-) delete mode 100755 source/agent/streaming/compile_ffmpeg_with_libsrt.sh diff --git a/scripts/installCentOSDeps.sh b/scripts/installCentOSDeps.sh index 03174f86f..002cc9fc2 100644 --- a/scripts/installCentOSDeps.sh +++ b/scripts/installCentOSDeps.sh @@ -40,7 +40,7 @@ installYumDeps(){ ${SUDO} yum install devtoolset-7-gcc* -y ${SUDO} yum install docbook2X -y ${SUDO} yum install libffi-devel -y - ${SUDO} yum install ca-certificates -y + ${SUDO} yum install ca-certificates tcl -y } installRepo(){ @@ -57,11 +57,13 @@ installRepo(){ } install_mediadeps_nonfree(){ + install_srt install_fdkaac install_ffmpeg } install_mediadeps(){ + install_srt install_ffmpeg } diff --git a/scripts/installCommonDeps.sh b/scripts/installCommonDeps.sh index 23eb54afe..3bf405642 100644 --- a/scripts/installCommonDeps.sh +++ b/scripts/installCommonDeps.sh @@ -21,7 +21,7 @@ check_proxy(){ } install_srt(){ - local VERSION="1.4.1" + local VERSION="1.4.4" local SRC="v${VERSION}.tar.gz" local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" local SRC_DIR="srt-${VERSION}" @@ -90,7 +90,6 @@ install_ffmpeg(){ local SRC="${DIR}.tar.bz2" local SRC_URL="http://ffmpeg.org/releases/${SRC}" local SRC_MD5SUM="9c2ca54e7f353a861e57525ff6da335b" - local SRT_OPTION=" " local LIST_LIBS=`ls ${PREFIX_DIR}/lib/libav* 2>/dev/null` [ "$INCR_INSTALL" = true ] && [[ ! -z $LIST_LIBS ]] && \ @@ -105,10 +104,6 @@ install_ffmpeg(){ return 0 fi - if [ "$ENABLE_SRT" = true ]; then - SRT_OPTION="--enable-libsrt" - fi - mkdir -p ${LIB_DIR} pushd ${LIB_DIR} [[ ! -s ${SRC} ]] && wget -c ${SRC_URL} @@ -121,8 +116,8 @@ install_ffmpeg(){ tar xf ${SRC} pushd ${DIR} [[ "${DISABLE_NONFREE}" == "true" ]] && \ - PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype ${SRT_OPTION} || \ - PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libfdk-aac --enable-nonfree ${SRT_OPTION} && \ + PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt || \ + PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libfdk-aac --enable-nonfree --enable-libsrt && \ make -j4 -s V=0 && make install popd popd diff --git a/scripts/installDeps.sh b/scripts/installDeps.sh index 46a408698..509bffd75 100755 --- a/scripts/installDeps.sh +++ b/scripts/installDeps.sh @@ -15,7 +15,6 @@ INCR_INSTALL=false CHECK_INSTALL=false ONLY_INSTALL="" ENABLE_WEBTRANSPORT=false -ENABLE_SRT=false SUDO="" if [[ $EUID -ne 0 ]]; then @@ -30,7 +29,6 @@ print_help(){ echo " --check check whether dependencies are installed" echo " --incremental skip dependencies which are already installed" echo " --enable-webtransport install dependencies with webtransport" - echo " --enable-srt install dependencies with srt" echo " --with-nonfree-libs install nonfree dependencies" echo " --cleanup remove intermediate files after installation" echo " --only [dep] only install specified dependency [dep]" @@ -60,9 +58,6 @@ parse_arguments(){ "--enable-webtransport") ENABLE_WEBTRANSPORT=true ;; - "--enable-srt") - ENABLE_SRT=true - ;; "--help") print_help ;; @@ -151,12 +146,6 @@ fi pause "Installing Node.js ... [press Enter]" install_node -if [ "$ENABLE_SRT" = "true" ]; then - [ "$CHECK_INSTALL" != true ] && \ - pause "Installing libsrt library.... [press Enter]" - install_srt -fi - if [ "$DISABLE_NONFREE" = "true" ]; then [ "$CHECK_INSTALL" != true ] && \ pause "Nonfree libraries disabled: aac transcoding unavailable. [press Enter]" diff --git a/scripts/installDepsUnattended.sh b/scripts/installDepsUnattended.sh index cf26c551c..b7aa998d3 100755 --- a/scripts/installDepsUnattended.sh +++ b/scripts/installDepsUnattended.sh @@ -34,7 +34,6 @@ print_help(){ echo " --check check whether dependencies are installed" echo " --incremental skip dependencies which are already installed" echo " --with-nonfree-libs install nonfree dependencies" - echo " --enable-srt install dependencies with srt" echo " --cleanup remove intermediate files after installation" echo " --help print help of this script" echo @@ -62,9 +61,6 @@ parse_arguments(){ "--check") CHECK_INSTALL=true ;; - "--enable-srt") - ENABLE_SRT=true - ;; esac shift done @@ -109,11 +105,6 @@ if [ "$GITHUB_ACTIONS" != "true" ]; then fi if [ "$NIGHTLY" != "true" ] && [ "$GITHUB_ACTIONS" != "true" ]; then - - if [ "$ENABLE_SRT" = "true" ]; then - install_srt - fi - if [ "$DISABLE_NONFREE" = "true" ]; then install_mediadeps else diff --git a/scripts/installUbuntuDeps.sh b/scripts/installUbuntuDeps.sh index 123862a8a..6ef6bf081 100644 --- a/scripts/installUbuntuDeps.sh +++ b/scripts/installUbuntuDeps.sh @@ -5,7 +5,7 @@ install_apt_deps(){ ${SUDO} apt-get install git make gcc g++ libglib2.0-dev docbook2x pkg-config -y ${SUDO} apt-get install libboost-regex-dev libboost-thread-dev libboost-system-dev liblog4cxx-dev -y ${SUDO} apt-get install openjdk-8-jre curl libboost-test-dev nasm yasm gyp libx11-dev libkrb5-dev intel-gpu-tools -y - ${SUDO} apt-get install m4 autoconf libtool automake cmake libfreetype6-dev libgstreamer-plugins-base1.0-dev -y + ${SUDO} apt-get install m4 autoconf libtool automake cmake libfreetype6-dev libgstreamer-plugins-base1.0-dev tcl -y if [ "$GITHUB_ACTIONS" != "true" ]; then ${SUDO} apt-get install rabbitmq-server mongodb -y else @@ -31,11 +31,13 @@ install_gcc_7(){ } install_mediadeps_nonfree(){ + install_srt install_fdkaac install_ffmpeg } install_mediadeps(){ + install_srt install_ffmpeg } diff --git a/scripts/release/install_ffmpeg.sh b/scripts/release/install_ffmpeg.sh index d2e284b78..f284ec5aa 100755 --- a/scripts/release/install_ffmpeg.sh +++ b/scripts/release/install_ffmpeg.sh @@ -17,10 +17,6 @@ echo $1 parse_arguments(){ while [ "$1" != "" ]; do case $1 in - "--enable-srt") - echo "Enable SRT" - ENABLE_SRT=true - ;; "--cleanup") CLEANUP=true ;; @@ -77,25 +73,19 @@ install_build_deps() { if [[ "$OS" =~ .*centos.* ]] then echo -e "\x1b[32mInstalling dependent components and libraries via yum...\x1b[0m" - ${SUDO} yum install pkg-config make gcc gcc-c++ nasm yasm freetype-devel -y - if [ "$ENABLE_SRT" = "true" ]; then - ${SUDO} yum install tcl openssl-devel cmake automake -y - fi + ${SUDO} yum install pkg-config make gcc gcc-c++ nasm yasm freetype-devel tcl openssl-devel cmake automake -y elif [[ "$OS" =~ .*ubuntu.* ]] then echo -e "\x1b[32mInstalling dependent components and libraries via apt-get...\x1b[0m" ${SUDO} apt-get update - ${SUDO} apt-get install pkg-config make gcc g++ nasm yasm libfreetype6-dev -y - if [ "$ENABLE_SRT" = "true" ]; then - ${SUDO} apt-get install tcl cmake libssl-dev build-essential -y - fi + ${SUDO} apt-get install pkg-config make gcc g++ nasm yasm libfreetype6-dev tcl cmake libssl-dev build-essential -y else echo -e "\x1b[32mUnsupported platform...\x1b[0m" fi } install_srt(){ - local VERSION="1.4.1" + local VERSION="1.4.4" local SRC="v${VERSION}.tar.gz" local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" local SRC_DIR="srt-${VERSION}" @@ -113,11 +103,11 @@ install_srt(){ } install_ffmpeg(){ - local VERSION="4.1.3" + local VERSION="4.4.1" local DIR="ffmpeg-${VERSION}" local SRC="${DIR}.tar.bz2" local SRC_URL="http://ffmpeg.org/releases/${SRC}" - local SRC_MD5SUM="9985185a8de3678e5b55b1c63276f8b5" + local SRC_MD5SUM="9c2ca54e7f353a861e57525ff6da335b" local PREFIX_DIR="${this}/ffmpeg-install" local LIST_LIBS=`ls ${this}/lib/libav* 2>/dev/null` @@ -133,13 +123,8 @@ install_ffmpeg(){ rm -fr ${DIR} tar xf ${SRC} pushd ${DIR} >/dev/null - if [ "$ENABLE_SRT" = "true" ]; then - PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ - --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt - else - CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ - --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype - fi + PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ + --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt make -j4 -s V=0 && make install popd popd @@ -153,9 +138,7 @@ parse_arguments $* echo "Install building dependencies..." install_build_deps -if [ "$ENABLE_SRT" = "true" ]; then install_srt -fi echo "Install ffmpeg..." install_ffmpeg diff --git a/source/agent/streaming/compile_ffmpeg_with_libsrt.sh b/source/agent/streaming/compile_ffmpeg_with_libsrt.sh deleted file mode 100755 index 893e48c07..000000000 --- a/source/agent/streaming/compile_ffmpeg_with_libsrt.sh +++ /dev/null @@ -1,141 +0,0 @@ -##!/usr/bin/env bash -# Copyright (C) <2019> Intel Corporation -# -# SPDX-License-Identifier: Apache-2.0 - -this=$(pwd) - -DOWNLOAD_DIR="${this}/ffmpeg_libsrt_src" -TARGET_DIR="${this}/ffmpeg_libsrt_lib" -SUDO="" -if [[ $EUID -ne 0 ]]; then - SUDO="sudo -E" -fi - -detect_OS() { - lsb_release >/dev/null 2>/dev/null - if [ $? = 0 ] - then - lsb_release -ds | sed 's/^\"//g;s/\"$//g' - # a bunch of fallbacks if no lsb_release is available - # first trying /etc/os-release which is provided by systemd - elif [ -f /etc/os-release ] - then - source /etc/os-release - if [ -n "${PRETTY_NAME}" ] - then - printf "${PRETTY_NAME}\n" - else - printf "${NAME}" - [[ -n "${VERSION}" ]] && printf " ${VERSION}" - printf "\n" - fi - # now looking at distro-specific files - elif [ -f /etc/arch-release ] - then - printf "Arch Linux\n" - elif [ -f /etc/gentoo-release ] - then - cat /etc/gentoo-release - elif [ -f /etc/fedora-release ] - then - cat /etc/fedora-release - elif [ -f /etc/redhat-release ] - then - cat /etc/redhat-release - elif [ -f /etc/debian_version ] - then - printf "Debian GNU/Linux " ; cat /etc/debian_version - else - printf "Unknown\n" - fi -} - -install_build_deps() { - local OS=$(detect_OS | awk '{print tolower($0)}') - echo $OS - - if [[ "$OS" =~ .*centos.* ]] - then - echo -e "\x1b[32mInstalling dependent components and libraries via yum...\x1b[0m" - ${SUDO} yum install pkg-config make gcc gcc-c++ nasm yasm freetype-devel -y - elif [[ "$OS" =~ .*ubuntu.* ]] - then - echo -e "\x1b[32mInstalling dependent components and libraries via apt-get...\x1b[0m" - ${SUDO} apt-get update - ${SUDO} apt-get install pkg-config make gcc g++ nasm yasm libfreetype6-dev -y - else - echo -e "\x1b[32mUnsupported platform...\x1b[0m" - fi -} - -install_srt(){ - local VERSION="1.4.1" - local SRC="v${VERSION}.tar.gz" - local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" - local SRC_DIR="srt-${VERSION}" - local PREFIX_DIR="${this}/ffmpeg-install" - mkdir -p ${LIB_DIR} - pushd ${LIB_DIR} - wget ${SRC_URL} - rm -fr ${SRC_DIR} - tar xf ${SRC} - pushd ${SRC_DIR} - ./configure --prefix=${PREFIX_DIR} - make && make install - popd - popd -} - -install_ffmpeg(){ - local VERSION="4.1.3" - local DIR="ffmpeg-${VERSION}" - local SRC="${DIR}.tar.bz2" - local SRC_URL="http://ffmpeg.org/releases/${SRC}" - local SRC_MD5SUM="9985185a8de3678e5b55b1c63276f8b5" - - echo "Downloading ffmpeg-${VERSION}" - [[ ! -s ${SRC} ]] && wget -c ${SRC_URL} - if ! (echo "${SRC_MD5SUM} ${SRC}" | md5sum --check) ; then - echo "Downloaded file ${SRC} is corrupted." - rm -v ${SRC} - return 1 - fi - rm -fr ${DIR} - tar xf ${SRC} - - echo "Building ffmpeg-${VERSION}" - pushd ${DIR} - PKG_CONFIG_PATH=${DOWNLOAD_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${DOWNLOAD_DIR} --enable-shared --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt && \ - make -j4 -s V=0 && make install - popd -} - -echo "This script will download and compile a libsrt enabled ffmpeg." -read -p "Continue to compile ffmpeg with libsrt? [No/yes]" yn -case $yn in - [Yy]* ) ;; - [Nn]* ) exit 0;; - * ) ;; -esac - -echo "Install building dependencies..." -install_build_deps - -[[ ! -d ${DOWNLOAD_DIR} ]] && mkdir ${DOWNLOAD_DIR}; - -pushd ${DOWNLOAD_DIR} -install_srt -install_ffmpeg -popd - -[[ ! -d ${TARGET_DIR} ]] && mkdir ${TARGET_DIR}; - -echo "Copy libs to ${TARGET_DIR}" -cp -P ${DOWNLOAD_DIR}/lib/*.so.* ${TARGET_DIR} -cp -P ${DOWNLOAD_DIR}/lib/*.so ${TARGET_DIR}/ - -echo "Compiling finish." -echo "Downloaded source dir: ${DOWNLOAD_DIR}" -echo "Compiled library dir: ${TARGET_DIR}" - diff --git a/source/agent/streaming/dist.json b/source/agent/streaming/dist.json index 1f4f25d05..ee560cb99 100644 --- a/source/agent/streaming/dist.json +++ b/source/agent/streaming/dist.json @@ -6,7 +6,6 @@ "files": [ "agent.toml", "log4js_configuration.json", - "compile_ffmpeg_with_libsrt.sh", "install_deps.sh", "configLoader.js", "../index.js", From e78890de10c9f1ce34b34f5f15601094b52c8eb1 Mon Sep 17 00:00:00 2001 From: qwu16 Date: Tue, 22 Feb 2022 10:30:04 +0800 Subject: [PATCH 3/5] Remove unused flag --- scripts/release/install_ffmpeg.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/release/install_ffmpeg.sh b/scripts/release/install_ffmpeg.sh index f284ec5aa..a973ea9b1 100755 --- a/scripts/release/install_ffmpeg.sh +++ b/scripts/release/install_ffmpeg.sh @@ -6,7 +6,6 @@ this=`dirname "$0"` this=`cd "$this"; pwd` SUDO="" -ENABLE_SRT=false if [[ $EUID -ne 0 ]]; then SUDO="sudo -E" fi From 34c61afe3bfc4ec1c2761a0b7ff8bddc75bc6b8c Mon Sep 17 00:00:00 2001 From: qwu16 Date: Tue, 22 Feb 2022 10:46:22 +0800 Subject: [PATCH 4/5] Remove unused print --- scripts/installDepsUnattended.sh | 1 - scripts/release/install_ffmpeg.sh | 16 ---------------- 2 files changed, 17 deletions(-) diff --git a/scripts/installDepsUnattended.sh b/scripts/installDepsUnattended.sh index b7aa998d3..9bde129c9 100755 --- a/scripts/installDepsUnattended.sh +++ b/scripts/installDepsUnattended.sh @@ -15,7 +15,6 @@ NO_INTERNAL=false INCR_INSTALL=false CHECK_INSTALL=false ENABLE_WEBTRANSPORT=false -ENABLE_SRT=false SUDO="" if [ "$GITHUB_ACTIONS" == "true" ]; then diff --git a/scripts/release/install_ffmpeg.sh b/scripts/release/install_ffmpeg.sh index a973ea9b1..c5e5350ea 100755 --- a/scripts/release/install_ffmpeg.sh +++ b/scripts/release/install_ffmpeg.sh @@ -10,22 +10,6 @@ if [[ $EUID -ne 0 ]]; then SUDO="sudo -E" fi -echo "Streaming agent install ffmpeg" -echo $1 - -parse_arguments(){ - while [ "$1" != "" ]; do - case $1 in - "--cleanup") - CLEANUP=true - ;; - esac - shift - done -} - - - detect_OS() { lsb_release >/dev/null 2>/dev/null if [ $? = 0 ] From 29aedf7d9079c52f8de59c209a1d6fecd96a2710 Mon Sep 17 00:00:00 2001 From: qwu16 Date: Tue, 22 Feb 2022 15:32:07 +0800 Subject: [PATCH 5/5] Only install srt in streaming agent --- scripts/installDepsUnattended.sh | 1 + scripts/release/init-all.sh | 2 +- scripts/release/install_ffmpeg.sh | 45 ++++++++++++++++++++++++++----- 3 files changed, 40 insertions(+), 8 deletions(-) diff --git a/scripts/installDepsUnattended.sh b/scripts/installDepsUnattended.sh index 9bde129c9..6d59b4176 100755 --- a/scripts/installDepsUnattended.sh +++ b/scripts/installDepsUnattended.sh @@ -104,6 +104,7 @@ if [ "$GITHUB_ACTIONS" != "true" ]; then fi if [ "$NIGHTLY" != "true" ] && [ "$GITHUB_ACTIONS" != "true" ]; then + if [ "$DISABLE_NONFREE" = "true" ]; then install_mediadeps else diff --git a/scripts/release/init-all.sh b/scripts/release/init-all.sh index 2cd099791..c9e351e5c 100644 --- a/scripts/release/init-all.sh +++ b/scripts/release/init-all.sh @@ -24,7 +24,6 @@ copy_video_libs() { cp ${ROOT}/video_agent/lib/* ${ROOT}/audio_agent/lib/ cp ${ROOT}/video_agent/lib/* ${ROOT}/recording_agent/lib/ - cp ${ROOT}/video_agent/lib/* ${ROOT}/streaming_agent/lib/ } init_software() @@ -39,6 +38,7 @@ init_software() ${ROOT}/webrtc_agent/install_deps.sh ${ROOT}/video_agent/install_deps.sh ${ROOT}/video_agent/init.sh + ${ROOT}/streaming_agent/install_deps.sh ${ROOT}/analytics_agent/install_deps.sh copy_video_libs else diff --git a/scripts/release/install_ffmpeg.sh b/scripts/release/install_ffmpeg.sh index c5e5350ea..b5132fc44 100755 --- a/scripts/release/install_ffmpeg.sh +++ b/scripts/release/install_ffmpeg.sh @@ -10,6 +10,14 @@ if [[ $EUID -ne 0 ]]; then SUDO="sudo -E" fi +ENABLE_SRT=false +SRT_OPTION=" " +AGENT=`echo $this | awk -F "/" '{print $NF}'` +if [ "$AGENT" = "streaming_agent" ]; then + ENABLE_SRT=true + SRT_OPTION="--enable-libsrt" +fi + detect_OS() { lsb_release >/dev/null 2>/dev/null if [ $? = 0 ] @@ -67,14 +75,37 @@ install_build_deps() { fi } +install_openssl(){ + local PREFIX_DIR="${this}/ffmpeg-install" + local LIST_LIBS=`ls ${PREFIX_DIR}/lib/libssl* 2>/dev/null` + pushd ${this} >/dev/null + [[ ! -z $LIST_LIBS ]] && \ + echo "openssl already installed." && return 0 + + local SSL_BASE_VERSION="1.1.1" + local SSL_VERSION="1.1.1m" + rm -rf openssl-1* + wget -c https://www.openssl.org/source/openssl-${SSL_VERSION}.tar.gz + tar xf openssl-${SSL_VERSION}.tar.gz + pushd openssl-${SSL_VERSION} + ./config no-ssl3 --prefix=$PREFIX_DIR -fPIC --libdir=lib + make depend + make -s V=0 + make install + + popd +} + install_srt(){ local VERSION="1.4.4" local SRC="v${VERSION}.tar.gz" local SRC_URL=" https://github.com/Haivision/srt/archive/${SRC}" local SRC_DIR="srt-${VERSION}" local PREFIX_DIR="${this}/ffmpeg-install" - mkdir -p ${LIB_DIR} - pushd ${LIB_DIR} + + local LIST_LIBS=`ls ${this}/lib/libsrt* 2>/dev/null` + pushd ${this} >/dev/null + [[ ! -z $LIST_LIBS ]] && echo "srt already installed." && return 0 wget ${SRC_URL} rm -fr ${SRC_DIR} tar xf ${SRC} @@ -82,7 +113,6 @@ install_srt(){ ./configure --prefix=${PREFIX_DIR} make && make install popd - popd } install_ffmpeg(){ @@ -107,7 +137,7 @@ install_ffmpeg(){ tar xf ${SRC} pushd ${DIR} >/dev/null PKG_CONFIG_PATH=${PREFIX_DIR}/lib/pkgconfig CFLAGS=-fPIC ./configure --prefix=${PREFIX_DIR} --enable-shared \ - --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype --enable-libsrt + --disable-static --disable-libvpx --disable-vaapi --enable-libfreetype ${SRT_OPTION} make -j4 -s V=0 && make install popd popd @@ -116,12 +146,13 @@ install_ffmpeg(){ cp -P ${PREFIX_DIR}/lib/*.so ${this}/lib/ } -parse_arguments $* - echo "Install building dependencies..." install_build_deps -install_srt +if [ "$ENABLE_SRT" = "true" ]; then + install_openssl + install_srt +fi echo "Install ffmpeg..." install_ffmpeg