Skip to content

Commit

Permalink
Update FFmpeg with AV1 and rist support
Browse files Browse the repository at this point in the history
Adds libaom for AV1 encoding support as well as librist as additional
streaming protocol.

Also adds FFmpeg patches for HLS streaming and additional CPU levels for
libaom.

Meson was added to list of build-time dependencies as librist requires
it.
  • Loading branch information
PatTheMav committed Nov 10, 2021
1 parent f9b079c commit 2aa0b21
Show file tree
Hide file tree
Showing 36 changed files with 1,581 additions and 43 deletions.
49 changes: 43 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
env:
MACOSX_DEPLOYMENT_TARGET_X86_64: '10.13'
MACOSX_DEPLOYMENT_TARGET_ARM64: '11.0'
CACHE_REVISION: '05'
CACHE_REVISION: '09'
LIBPNG_VERSION: '1.6.37'
LIBPNG_HASH: '505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca'
LIBOPUS_VERSION: '1.3.1-93-gdfd6c88a'
Expand All @@ -33,6 +33,8 @@ jobs:
LIBVORBIS_HASH: 'b33cc4934322bcbf6efcbacf49e3ca01aadbea4114ec9589d1b1e9d20f72954b'
LIBVPX_VERSION: '1.10.0'
LIBVPX_HASH: '85803ccbdbdd7a3b03d930187cb055f1353596969c1f92ebec2db839fa4f834a'
LIBAOM_VERSION: '3.2.0'
LIBAOM_HASH: '287164de79516c25c8c84fd544f67752c170082a'
LIBX264_VERSION: 'r3059'
LIBX264_HASH: 'b684ebe04a6f80f8207a57940a1fa00e25274f81'
LIBTHEORA_VERSION: '1.1.1'
Expand All @@ -43,8 +45,10 @@ jobs:
MBEDTLS_HASH: '35d8d87509cd0d002bddbd5508b9d2b931c5e83747d087234cc7ad551d53fe05'
LIBSRT_VERSION: '1.4.1'
LIBSRT_HASH: 'e80ca1cd0711b9c70882c12ec365cda1ba852e1ce8acd43161a21a04de0cbf14'
FFMPEG_VERSION: '4.2.3'
FFMPEG_HASH: '9df6c90aed1337634c1fb026fb01c154c29c82a64ea71291ff2da9aacb9aad31'
LIBRIST_VERSION: '0.2.6'
LIBRIST_HASH: '88b35b86af1ef3d306f33674f2d9511a27d3ff4ec76f20d3a3b3273b79a4521d'
FFMPEG_VERSION: '4.4.1'
FFMPEG_HASH: 'eadbad9e9ab30b25f5520fbfde99fae4a92a1ae3c0257a8d68569a4651e30e02'
SPEEXDSP_VERSION: '1.2.0'
SPEEXDSP_HASH: 'd7032f607e8913c019b190c2bccc36ea73fc36718ee38b5cdfc4e4c0a04ce9a4'
LIBJANSSON_VERSION: '2.13.1'
Expand Down Expand Up @@ -104,7 +108,22 @@ jobs:
brew bundle --file "CI/include/Brewfile"
echo "/usr/local/opt/gnu-tar/libexec/gnubin" >> $GITHUB_PATH
FFMPEG_DEP_HASH="$(echo "${{ env.LIBPNG_VERSION }}-${{ env.LIBLAME_VERSION }}-${{ env.LIBOGG_VERSION }}-${{ env.LIBVORBIS_VERSION }}-${{ env.LIBVPX_VERSION }}-${{ env.LIBOPUS_VERSION }}-${{ env.LIBX264_VERSION }}-${{ env.LIBSRT_VERSION }}-${{ env.LIBMBEDTLS_VERSION }}-${{ env.LIBTHEORA_VERSION }}" | sha256sum | cut -d " " -f 1)"
FFMPEG_DEPS=(\
"${{ env.LIBPNG_VERSION }}" \
"${{ env.LIBLAME_VERSION }}" \
"${{ env.LIBOGG_VERSION }}" \
"${{ env.LIBVORBIS_VERSION }}" \
"${{ env.LIBVPX_VERSION }}" \
"${{ env.LIBOPUS_VERSION }}" \
"${{ env.LIBAOM_VERSION }}" \
"${{ env.LIBX264_VERSION }}" \
"${{ env.LIBSRT_VERSION }}" \
"${{ env.LIBRIST_VERSION }}" \
"${{ env.MBEDTLS_VERSION }}" \
"${{ env.LIBTHEORA_VERSION }}"
)
FFMPEG_DEP_HASH="$(echo "${FFMPEG_DEPS}" | sha256sum | cut -d " " -f 1)"
echo "FFMPEG_DEP_HASH=$FFMPEG_DEP_HASH" >> $GITHUB_ENV
- name: 'Restore ffmpeg dependencies from cache'
Expand All @@ -119,20 +138,22 @@ jobs:
${{ github.workspace }}/macos_build_temp/libogg-${{ env.LIBOGG_VERSION }}
${{ github.workspace }}/macos_build_temp/libvorbis-${{ env.LIBVORBIS_VERSION }}
${{ github.workspace }}/macos_build_temp/libvpx-${{ env.LIBVPX_VERSION }}
${{ github.workspace }}/macos_build_temp/aom-${{ env.LIBAOM_VERSION }}
${{ github.workspace }}/macos_build_temp/x264-${{ env.LIBX264_VERSION }}
${{ github.workspace }}/macos_build_temp/libtheora-${{ env.LIBTHEORA_VERSION }}
${{ github.workspace }}/macos_build_temp/lame-${{ env.LIBLAME_VERSION }}
${{ github.workspace }}/macos_build_temp/mbedtls-mbedtls-${{ env.MBEDTLS_VERSION }}
${{ github.workspace }}/macos_build_temp/librist-v${{ env.LIBRIST_VERSION }}
${{ github.workspace }}/macos_build_temp/srt-${{ env.LIBSRT_VERSION }}
key: ${{ runner.os }}-${{ env.CACHE_NAME }}-${{ env.FFMPEG_DEP_HASH }}

- name: 'Build dependency libpng'
if: steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
run: CI/macos/build_libpng.sh -a ${{ matrix.arch }}
run: CI/macos/build_libpng.sh -s -a ${{ matrix.arch }}

- name: 'Install dependency libpng'
if: steps.ffmpeg-deps-cache.outputs.cache-hit == 'true'
run: CI/macos/build_libpng.sh -a ${{ matrix.arch }} --install
run: CI/macos/build_libpng.sh -s -a ${{ matrix.arch }} --install

- name: 'Build dependency libopus'
if: steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
Expand Down Expand Up @@ -174,6 +195,14 @@ jobs:
if: steps.ffmpeg-deps-cache.outputs.cache-hit == 'true'
run: CI/macos/build_libx264.sh -s -a ${{ matrix.arch }} --install

- name: 'Build dependency libaom'
if: steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
run: CI/macos/build_libaom.sh -s -a ${{ matrix.arch }}

- name: 'Install dependency libaom'
if: steps.ffmpeg-deps-cache.outputs.cache-hit == 'true'
run: CI/macos/build_libaom.sh -s -a ${{ matrix.arch }} --install

- name: 'Build dependency libtheora'
if: steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
run: CI/macos/build_libtheora.sh -s -a ${{ matrix.arch }}
Expand Down Expand Up @@ -206,6 +235,14 @@ jobs:
if: steps.ffmpeg-deps-cache.outputs.cache-hit == 'true'
run: CI/macos/build_libsrt.sh -s -a ${{ matrix.arch }} --install

- name: 'Build dependency librist'
if: steps.ffmpeg-deps-cache.outputs.cache-hit != 'true'
run: CI/macos/build_librist.sh -s -a ${{ matrix.arch }}

- name: 'Install dependency librist'
if: steps.ffmpeg-deps-cache.outputs.cache-hit == 'true'
run: CI/macos/build_librist.sh -s -a ${{ matrix.arch }} --install

- name: 'Restore ffmpeg from cache'
id: ffmpeg-cache
uses: actions/[email protected]
Expand Down
6 changes: 3 additions & 3 deletions CI/build-deps-macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,19 @@ set -eE
_RUN_OBS_BUILD_SCRIPT=TRUE
PRODUCT_NAME="obs-deps"
REQUIRED_DEPS=(
"macosx "
"libpng 1.6.37 505e70834d35383537b6491e7ae8641f1a4bed1876dbfe361201fc80868d88ca"
"libopus 1.3.1-93-gdfd6c88a dfd6c88aaa54a03a61434c413e30c217eb98f1d5"
"libogg 1.3.5 c4d91be36fc8e54deae7575241e03f4211eb102afb3fc0775fbbc1b740016705"
"libvorbis 1.3.7 b33cc4934322bcbf6efcbacf49e3ca01aadbea4114ec9589d1b1e9d20f72954b"
"libvpx 1.10.0 85803ccbdbdd7a3b03d930187cb055f1353596969c1f92ebec2db839fa4f834a"
"libaom 3.2.0 287164de79516c25c8c84fd544f67752c170082a"
"libx264 r3059 b684ebe04a6f80f8207a57940a1fa00e25274f81"
"libtheora 1.1.1 f36da409947aa2b3dcc6af0a8c2e3144bc19db2ed547d64e9171c59c66561c61"
"liblame 3.100 ddfe36cab873794038ae2c1210557ad34857a4b6bdc515785d1da9e175b1da1e"
"mbedtls 2.26.0 35d8d87509cd0d002bddbd5508b9d2b931c5e83747d087234cc7ad551d53fe05"
"libsrt 1.4.1 e80ca1cd0711b9c70882c12ec365cda1ba852e1ce8acd43161a21a04de0cbf14"
"ffmpeg 4.2.3 9df6c90aed1337634c1fb026fb01c154c29c82a64ea71291ff2da9aacb9aad31"
"librist 0.2.6 88b35b86af1ef3d306f33674f2d9511a27d3ff4ec76f20d3a3b3273b79a4521d"
"ffmpeg 4.4.1 eadbad9e9ab30b25f5520fbfde99fae4a92a1ae3c0257a8d68569a4651e30e02"
"speexdsp 1.2.0 d7032f607e8913c019b190c2bccc36ea73fc36718ee38b5cdfc4e4c0a04ce9a4"
"libjansson 2.13.1 f4f377da17b10201a60c1108613e78ee15df6b12016b116b6de42209f47a474f"
"libluajit 2.1 ec6edc5c39c25e4eb3fca51b753f9995e97215da"
Expand All @@ -44,7 +45,6 @@ REQUIRED_DEPS=(

## MAIN SCRIPT FUNCTIONS ##
obs-deps-build-main() {
QMAKE_QUIET=TRUE
CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
BUILD_DIR="${CHECKOUT_DIR}/../obs-prebuilt-dependencies"
source "${CHECKOUT_DIR}/CI/include/build_support.sh"
Expand Down
2 changes: 2 additions & 0 deletions CI/include/Brewfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
brew "nasm"
brew "yasm"
brew "gnu-tar"
brew "pkg-config"
brew "automake"
Expand All @@ -7,3 +8,4 @@ brew "coreutils"
brew "cmake"
brew "ccache"
brew "ninja"
brew "meson"
56 changes: 34 additions & 22 deletions CI/include/build_support.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,27 +11,39 @@

## DEFINE UTILITIES ##

status() {
script_output "${COLOR_BLUE}[${PRODUCT_NAME}] ${1}${COLOR_RESET}"
}

step() {
script_output "${COLOR_GREEN} + ${1}${COLOR_RESET}"
}

info() {
script_output "${COLOR_ORANGE} + ${1}${COLOR_RESET}"
}

error() {
echo -e "${COLOR_RED} + ${1}${COLOR_RESET}"
}

script_output() {
if [ -z "${QUIET}" ]; then
echo -e "${1}"
fi
}
if [ -z "${QUIET}" ]; then
status() {
echo -e "${COLOR_BLUE}[${PRODUCT_NAME}] ${1}${COLOR_RESET}"
}

step() {
echo -e "${COLOR_GREEN} + ${1}${COLOR_RESET}"
}

info() {
echo -e "${COLOR_ORANGE} + ${1}${COLOR_RESET}"
}

error() {
echo -e "${COLOR_RED} + ${1}${COLOR_RESET}"
}
else
status() {
:
}

step() {
:
}

info() {
:
}

error() {
echo -e "${COLOR_RED} + ${1}${COLOR_RESET}"
}
fi

exists() {
/usr/bin/command -v "$1" >/dev/null 2>&1
Expand Down Expand Up @@ -153,7 +165,7 @@ github_fetch() {
git config remote.origin.fetch "+refs/heads/master:refs/remotes/origin/master"
git config remote.origin.tapOpt --no-tags

if ! git rev-parse -q --verify "${GH_COMMIT}^{commit}"; then
if ! git rev-parse -q --verify "${GH_REF}^{commit}"; then
git fetch origin
fi

Expand Down
2 changes: 2 additions & 0 deletions CI/include/build_support_macos.sh
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ install_homebrew_deps() {
fi

brew bundle --file "${CHECKOUT_DIR}/CI/include/Brewfile" ${QUIET:+--quiet}

check_curl
}

check_curl() {
Expand Down
12 changes: 10 additions & 2 deletions CI/macos/build_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
# Halt on errors
set -eE

_patch_product() {
cd "${PRODUCT_FOLDER}"

step "Apply patches..."
apply_patch "${CHECKOUT_DIR}/CI/patches/FFmpeg-9010.patch" "97ac6385c2b7a682360c0cfb3e311ef4f3a48041d3f097d6b64f8c13653b6450"
apply_patch "${CHECKOUT_DIR}/CI/patches/FFmpeg-4.4.1-OBS.patch" "710fb5a381f7b68c95dcdf865af4f3c63a9405c305abef55d24c7ab54e90b182"
}

_fixup_ffmpeg_libs() {
LIBS=$(find "${BUILD_DIR}/lib" -type f \( -name "libav*.dylib" -o -name "libsw*.dylib" -o -name "libpostproc*.dylib" \))

Expand Down Expand Up @@ -67,7 +75,7 @@ _build_product() {
step "Configure (x86_64)..."

PKG_CONFIG_PATH="${BUILD_DIR}/lib/pkgconfig" ../configure \
--enable-libx264 --enable-libopus --enable-libvorbis --enable-libvpx --enable-libsrt --enable-libtheora --enable-libmp3lame --enable-version3 --enable-gpl --enable-videotoolbox \
--enable-libx264 --enable-libopus --enable-libvorbis --enable-libvpx --enable-libsrt --enable-librist --enable-libtheora --enable-libmp3lame --enable-libaom --enable-version3 --enable-gpl --enable-videotoolbox \
--disable-libjack --disable-indev=jack --disable-outdev=sdl --disable-programs --disable-doc \
--enable-cross-compile --enable-shared --disable-static --enable-pthreads \
--shlibdir="${BUILD_DIR}/lib" --pkg-config-flags="--static" --prefix="${BUILD_DIR}" --enable-rpath \
Expand All @@ -86,7 +94,7 @@ _build_product() {

step "Configure (arm64)..."
PKG_CONFIG_PATH="${BUILD_DIR}/lib/pkgconfig" ../configure \
--enable-libx264 --enable-libopus --enable-libvorbis --enable-libvpx --enable-libsrt --enable-libtheora --enable-libmp3lame --enable-version3 --enable-gpl --enable-videotoolbox \
--enable-libx264 --enable-libopus --enable-libvorbis --enable-libvpx --enable-libsrt --enable-librist --enable-libtheora --enable-libmp3lame --enable-libaom --enable-version3 --enable-gpl --enable-videotoolbox \
--disable-libjack --disable-indev=jack --disable-outdev=sdl --disable-programs --disable-doc \
--enable-cross-compile --enable-shared --disable-static --enable-pthreads --enable-rpath \
--shlibdir="${BUILD_DIR}/lib" --pkg-config-flags="--static" --prefix="${BUILD_DIR}" \
Expand Down
111 changes: 111 additions & 0 deletions CI/macos/build_libaom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
#!/bin/bash

##############################################################################
# macOS libaom build script
##############################################################################
#
# This script file can be included in build scripts for macOS or run directly
#
##############################################################################

# Halt on errors
set -eE

_build_product() {
cd "${PRODUCT_FOLDER}"

step "Configure ("${ARCH}")..."
if [ "${CURRENT_ARCH}" = "arm64" ]; then
_DISABLE_CPU_DETECT="-DCONFIG_RUNTIME_CPU_DETECT=0"
fi

cmake -S . -B build_${ARCH} -G Ninja ${CMAKE_CCACHE_OPTIONS} \
-DCMAKE_INSTALL_PREFIX="${BUILD_DIR}" \
-DCMAKE_PREFIX_PATH="${BUILD_DIR}" \
-DCMAKE_OSX_ARCHITECTURES="${CMAKE_ARCHS}" \
-DAOM_TARGET_CPU="${ARCH}" \
-DENABLE_DOCS=OFF \
-DENABLE_EXAMPLES=OFF \
-DENABLE_TESTDATA=OFF \
-DENABLE_TESTS=OFF \
-DENABLE_TOOLS=OFF \
-DBUILD_SHARED_LIBS=OFF \
${_DISABLE_CPU_DETECT} \
${QUIET:+-Wno-deprecated -Wno-dev --log-level=ERROR}

step "Compile ("${ARCH}")..."
cmake --build build_${ARCH} --config "Release"
}

_install_product() {
cd "${PRODUCT_FOLDER}"

step "Install ("${ARCH}").."
cmake --install build_${ARCH} --config "Release"
}

_build_setup_aom() {
trap "caught_error 'build-libaom'" ERR

ensure_dir "${CHECKOUT_DIR}/macos_build_temp"

step "Git checkout..."
mkdir -p "${PRODUCT_REPO}-${PRODUCT_VERSION:-${CI_PRODUCT_VERSION}}"
cd "${PRODUCT_REPO}-${PRODUCT_VERSION:-${CI_PRODUCT_VERSION}}"

if [ -d "./.git" ]; then
info "Repository ${PRODUCT_REPO} already exists, updating..."
git config advice.detachedHead false
git config remote.origin.url "https://aomedia.googlesource.com/${PRODUCT_REPO}.git"
git config remote.origin.fetch "+refs/heads/master:refs/remotes/origin/master"
git config remote.origin.tapOpt --no-tags

if ! git rev-parse -q --verify "${PRODUCT_HASH:-${CI_PRODUCT_HASH}}^{commit}"; then
git fetch origin
fi

git checkout -f "${PRODUCT_HASH:-${CI_PRODUCT_HASH}}" --
git reset --hard "${PRODUCT_HASH:-${CI_PRODUCT_HASH}}" --
if [ -d "./.gitmodules" ]; then
git submodule foreach --recursive git submodule sync
git submodule update --init --recursive
fi
else
git clone "https://aomedia.googlesource.com/${PRODUCT_REPO}.git" "$(pwd)"
git config advice.detachedHead false
info "Checking out commit ${PRODUCT_HASH:-${CI_PRODUCT_HASH}}..."
git checkout -f "${PRODUCT_HASH:-${CI_PRODUCT_HASH}}" --

if [ -d "./.gitmodules" ]; then
git submodule foreach --recursive git submodule sync
git submodule update --init --recursive
fi
fi
}

build-libaom-main() {
PRODUCT_NAME="${PRODUCT_NAME:-libaom}"

if [ -z "${_RUN_OBS_BUILD_SCRIPT}" ]; then
CHECKOUT_DIR="$(/usr/bin/git rev-parse --show-toplevel)"
source "${CHECKOUT_DIR}/CI/include/build_support.sh"
source "${CHECKOUT_DIR}/CI/include/build_support_macos.sh"

_check_parameters $*
_build_checks
fi

PRODUCT_REPO="aom"
PRODUCT_PROJECT="libaom"
PRODUCT_FOLDER="${PRODUCT_REPO}-${PRODUCT_VERSION:-${CI_PRODUCT_VERSION}}"

if [ -z "${INSTALL}" ]; then
_add_ccache_to_path
_build_setup_aom
_build
else
_install_product
fi
}

build-libaom-main $*
Loading

0 comments on commit 2aa0b21

Please sign in to comment.