Skip to content

Commit

Permalink
Update FFmpeg to 4.4.1 and add librist dep for Windows
Browse files Browse the repository at this point in the history
For windows obs-deps, this:
- adds librist dependency to FFmpeg,
- updates FFmpeg from 4.2.4 to 4.4.1.
For mac librist dep, this corrects  the list of librist.c commits patched (one commit had been forgotten).
  • Loading branch information
pkviet committed Dec 20, 2021
1 parent 42f0384 commit caf78ee
Show file tree
Hide file tree
Showing 6 changed files with 195 additions and 56 deletions.
14 changes: 10 additions & 4 deletions .github/workflows/windows_deps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,14 @@ jobs:
LIBVORBIS_HASH: '83a82dd9296400d811b78c06e9ca429e24dd1e5c'
LIBVPX_VERSION: '1.8.1'
LIBVPX_HASH: '8ae686757b708cd8df1d10c71586aff5355cfe1e'
NV-CODEC-HEADERS_VERSION: '9.0.18.2'
NV-CODEC-HEADERS_HASH: '96a6db017b096ad48612890083464a7214902afa'
NV-CODEC-HEADERS_VERSION: '11.1.5.0'
NV-CODEC-HEADERS_HASH: 'e81e2ba5e8f365d47d91c8c8688769f62614b644'
AMF_VERSION: '1.4.16.1'
AMF_HASH: '802f92ee52b9efa77bf0d3ea8bfaed6040cdd35e'
FFMPEG_VERSION: '4.2.4'
FFMPEG_HASH: 'f9f95ceebfbd7b7f43c1b7ad34e25d366e6e2d2b'
LIBRIST_VERSION: '0.27'
LIBRIST_HASH: '0b1aaf995c4cad83d562ec7887180cc6ee132c84'
FFMPEG_VERSION: '4.4.1'
FFMPEG_HASH: 'cc33e73618a981de7fd96385ecb34719de031f16'
defaults:
run:
shell: bash
Expand Down Expand Up @@ -195,6 +197,10 @@ jobs:
if: steps.ffmpeg-deps-cache.outputs.cache-hit == 'true'
run: CI/windows/build_amf.sh -s -a ${{ matrix.arch }} --install

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

- name: 'Restore ffmpeg from cache'
id: ffmpeg-cache
uses: actions/cache@v2.1.6
Expand Down
5 changes: 3 additions & 2 deletions CI/build-deps-windows-cross.sh
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,10 @@ REQUIRED_DEPS=(
"libogg 1.3.4 31bd3f2707fb7dbae539a7093ba1fc4b2b37d84e"
"libvorbis 1.3.7 83a82dd9296400d811b78c06e9ca429e24dd1e5c"
"libvpx 1.8.1 8ae686757b708cd8df1d10c71586aff5355cfe1e"
"nv-codec-headers 9.0.18.2 96a6db017b096ad48612890083464a7214902afa"
"nv-codec-headers 11.1.5.0 e81e2ba5e8f365d47d91c8c8688769f62614b644"
"amf 1.4.16.1 802f92ee52b9efa77bf0d3ea8bfaed6040cdd35e"
"ffmpeg 4.2.4 f9f95ceebfbd7b7f43c1b7ad34e25d366e6e2d2b"
"librist 0.27 0b1aaf995c4cad83d562ec7887180cc6ee132c84"
"ffmpeg 4.4.1 cc33e73618a981de7fd96385ecb34719de031f16"
)

## MAIN SCRIPT FUNCTIONS ##
Expand Down
11 changes: 7 additions & 4 deletions CI/macos/build_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,16 @@ _patch_product() {
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"
# The librist patch consists in these 2 commits which haven't been backported to FFmpeg 4.1 :
# [1] avformat/librist: replace deprecated functions

# The librist patch consists in these 3 commits which haven't been backported to FFmpeg 4.4 :
# [1] avformat/internal: Move ff_read_line_to_bprint_overwrite to avio_internal.h
# https://github.com/FFmpeg/FFmpeg/commit/fd101c9c3bcdeb2d74274aaeaa968fe8ead3622d#diff-bc82665cda5e82b13bcd3e1ee74d820952d80acba839ac46ffed3f0785644200
# [2] avformat/librist: replace deprecated functions
# https://github.com/FFmpeg/FFmpeg/commit/5274f2f7f8c5e40d18b84055fbb232752bd24f2f#diff-bc82665cda5e82b13bcd3e1ee74d820952d80acba839ac46ffed3f0785644200
# [2] avformat/librist: correctly initialize logging_settings
# [3] avformat/librist: correctly initialize logging_settings
# https://github.com/FFmpeg/FFmpeg/commit/9b15f43cf8c7976fba115da686a990377f7b5ab9
# The following is an important patch submitted by librist devs, but not yet merged into FFmpeg master
# [3] avformat/librist: allow setting fifo size and fail on overflow.
# [4] avformat/librist: allow setting fifo size and fail on overflow.
# http://ffmpeg.org/pipermail/ffmpeg-devel/2021-November/287914.html
apply_patch "${CHECKOUT_DIR}/CI/patches/FFmpeg-4.4.1-librist.patch" "1B95F21375421830263A73C74B80852E60EFE10991513CFCC8FB7CBE066887F5"
}
Expand Down
58 changes: 12 additions & 46 deletions CI/windows/build_ffmpeg.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,52 +23,17 @@ _patch_product() {
git add .
git commit -m "Fix decoding of certain malformed FLV files"

# cherry pick commits for SRT fixes
# 1f7b527194a2 avformat/libsrt: check av_strdup() return value and fix memleak
# f9d6addd60b3 avformat/libsrt: fix for the memory leak if passphrase has been configured by option
# 79d907774d59 avformat/libsrt: change tlpktdrop, nakreport, messageapi options to boolean type
# 8d823e6005fe lavf/libsrt: add linger parameter to libsrt
# 952fd0c76874 lavf/libsrt: enable other encryption parameters
# d7e2a2bb35e3 lavf/libsrt: add version guard for srt encryption control
# 3def315c5c3b lavf/libsrt: Fix typo
# f8990c5f414d avformat/libsrt: fix enabling nonblocking mode
# fee4cafbf52f avformat/libsrt: add missing SRT_VERSION_VALUE check
# b96bc946f219 avformat/libsrt: fix timeout unit confusion between milisec and microsec
# 006744bdbd83 avformat/libsrt: fix name of timeout option
# aab9133d919b avformat/libsrt: fix checking connection result in non-blocking mode
# c112fae6603f avformat/libsrt: poll for error conditions as well
# 86a7b77b6048 avformat/libsrt: small fixes in libsrt_neterrno()
# 7cc7680a802c avformat/libsrt: send non-blocking mode on both the listen and the connect socket
# 449e984192d9 avformat/libsrt: use listen_timeout for listening
# 290a35aefed2 avformat/libsrt: make avformat connect timeout 0 by default
# 6e95ce8cc9ae avformat/libsrt: clarify option description for timeout and latency unit of measurement
# e9b35a249d22 avformat/libsrt: change open_timeout to int64_t to avoid integer overflow
# 7c59e1b0f285 lavf/srt: fix build fail when used the libsrt 1.4.1
# 86f5fd471d35 avformat/libsrt: close listen fd in listener mode
# fb0304fcc9f7 avformat/libsrt: fix cleanups on failed libsrt_open() and libsrt_setup()

git cherry-pick 1f7b527194a2a10c334b0ff66ec0a72f4fe65e08 \
f9d6addd60b3f9ac87388fe4ae0dc217235af81d \
79d907774d59119dcfd1c04dae97b52890aec3ec \
8d823e6005febef23ca10ccd9d8725e708167aeb \
952fd0c768747a0f910ce8b689fd23d7c67a51f8 \
d7e2a2bb35e394287b3e3dc27744830bf0b7ca99 \
3def315c5c3baa26c4f6b7ac4622aa8a3bfb46f8 \
f8990c5f414d4575415e2a3981c3b142222ca3d4 \
fee4cafbf52f81ffd6ad7ed4fd0a8096f8791886 \
b96bc946f219fbd28cffc1efea78fd42f34148ec \
006744bdbd83d98bc71cb041d9551bf6a64b45a2 \
aab9133d919bec4af54a06216d8629ebe4fb8f74 \
c112fae6603f8be33cf1ee2ae390ec939812f473 \
86a7b77b60488758e0c080882899c32c4a5ee017 \
7cc7680a802c1eee9e334a0653f2347e9c0922a4 \
449e984192d94ac40713e9217871c884657dc79d \
290a35aefed250a797449c34d2f9e5af0c4e006a \
6e95ce8cc9ae30e0e617e96e8d7e46a696b8965e \
e9b35a249d224b2a93ffe45a1ffb7448972b83f3 \
7c59e1b0f285cd7c7b35fcd71f49c5fd52cf9315 \
86f5fd471d35423e3bd5c9d2bd0076b14124faee \
fb0304fcc9f79a4c9cbdf347f20f484529f169ba
# The librist patch consists in these 3 commits which haven't been backported to FFmpeg 4.4 :
# [1] avformat/internal: Move ff_read_line_to_bprint_overwrite to avio_internal.h
# https://github.com/FFmpeg/FFmpeg/commit/fd101c9c3bcdeb2d74274aaeaa968fe8ead3622d#diff-bc82665cda5e82b13bcd3e1ee74d820952d80acba839ac46ffed3f0785644200
# [2] avformat/librist: replace deprecated functions
# https://github.com/FFmpeg/FFmpeg/commit/5274f2f7f8c5e40d18b84055fbb232752bd24f2f#diff-bc82665cda5e82b13bcd3e1ee74d820952d80acba839ac46ffed3f0785644200
# [3] avformat/librist: correctly initialize logging_settings
# https://github.com/FFmpeg/FFmpeg/commit/9b15f43cf8c7976fba115da686a990377f7b5ab9
# The following is an important patch submitted by librist devs, but not yet merged into FFmpeg master
# [4] avformat/librist: allow setting fifo size and fail on overflow.
# http://ffmpeg.org/pipermail/ffmpeg-devel/2021-November/287914.html
apply_patch "${CHECKOUT_DIR}/CI/patches/FFmpeg-4.4.1-librist.patch" "1B95F21375421830263A73C74B80852E60EFE10991513CFCC8FB7CBE066887F5"
}

_build_product() {
Expand All @@ -94,6 +59,7 @@ _build_product() {
--enable-libvorbis \
--enable-libvpx \
--enable-libsrt \
--enable-librist \
--disable-debug \
--cross-prefix=$WIN_CROSS_TOOL_PREFIX-w64-mingw32- \
--target-os=mingw32 \
Expand Down
123 changes: 123 additions & 0 deletions CI/windows/build_librist.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
#!/bin/bash

###############################################################################
# Windows librist cross-compile build script
###############################################################################
#
# This script file can be included in build scripts for Windows or run directly
#
###############################################################################

# Halt on errors
set -eE

_patch_product() {
cd "${PRODUCT_FOLDER}"

step "Apply patches..."
if [ ! -f "cross_mingw32.txt" ] || [ ! -f "cross_mingw64.txt" ]; then
apply_patch "${CHECKOUT_DIR}/CI/windows/patches/librist/librist.patch" "F7417521457C875B901209F849EFDDB092A2BB6897A2797F22FE843EE5AA2363"
fi
}

_build_product() {
cd "${PRODUCT_FOLDER}"
BASE_DIR="$(pwd)"

if [ "${ARCH}" = "x86_64" ]; then
step "Configure (x86_64)..."
meson setup build_x86_64 \
--cross-file cross_mingw64.txt \
--buildtype release \
--prefix "${BUILD_DIR}" \
-Dtest=false \
-Dbuilt_tools=false \
-Dhave_mingw_pthreads=true \
-Dpkg_config_path="${BUILD_DIR}/lib/pkgconfig"

step "Build (x86_64)..."
meson compile -C build_x86_64
fi

if [ "${ARCH}" = "x86" ]; then
step "Configure (x86)..."
meson setup build_x86 \
--cross-file cross_mingw32.txt \
--buildtype release \
--prefix "${BUILD_DIR}" \
-Dtest=false \
-Dbuilt_tools=false \
-Dhave_mingw_pthreads=true \
-Dpkg_config_path="${BUILD_DIR}/lib/pkgconfig"

step "Build (x86)..."
meson compile -C build_x86
fi


}

_install_product() {
cd "${PRODUCT_FOLDER}"

step "Install (${ARCH})..."
meson install -C build_${ARCH}
}

_build_setup_rist() {
trap "caught_error 'build-librist'" ERR

ensure_dir "${CHECKOUT_DIR}/windows_cross_build_temp"

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

if [ -d "./.git" ]; then
info "Repository ${PRODUCT_REPO} already exists, updating..."
git config advice.detachedHead false
git config remote.origin.url "https://code.videolan.org/rist/librist.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}}" --
else
git clone "https://code.videolan.org/rist/librist.git" "$(pwd)"
git config advice.detachedHead false
info "Checking out commit ${PRODUCT_HASH:-${CI_PRODUCT_HASH}}..."
git checkout -f "${PRODUCT_HASH:-${CI_PRODUCT_HASH}}" --

fi
}

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

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_windows_cross.sh"

_check_parameters $*
_build_checks
fi

NOCONTINUE=TRUE
PRODUCT_REPO="librist"
PRODUCT_PROJECT="librist"
PRODUCT_FOLDER="librist"

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

build-librist-main $*
40 changes: 40 additions & 0 deletions CI/windows/patches/librist/librist.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
diff --git a/cross_mingw32.txt b/cross_mingw32.txt
new file mode 100644
index 0000000..95b66a0
--- /dev/null
+++ b/cross_mingw32.txt
@@ -0,0 +1,14 @@
+[host_machine]
+system = 'windows'
+cpu_family = 'x86'
+cpu = 'i686'
+endian = 'little'
+
+[binaries]
+c = 'i686-w64-mingw32-gcc'
+cpp = 'i686-w64-mingw32-g++'
+ar = 'i686-w64-mingw32-ar'
+ranlib = 'i686-w64-mingw32-ranlib'
+strip = 'i686-w64-mingw32-strip'
+windres = 'i686-w64-mingw32-windres'
+pkgconfig = 'i686-w64-mingw32-pkg-config'
diff --git a/cross_mingw64.txt b/cross_mingw64.txt
new file mode 100644
index 0000000..09f7af0
--- /dev/null
+++ b/cross_mingw64.txt
@@ -0,0 +1,14 @@
+[binaries]
+c = 'x86_64-w64-mingw32-gcc'
+cpp = 'x86_64-w64-mingw32-g++'
+ld = 'x86_64-w64-mingw32-ld'
+ar = 'x86_64-w64-mingw32-ar'
+strip = 'x86_64-w64-mingw32-strip'
+pkgconfig = 'x86_64-w64-mingw32-pkg-config'
+objdump = 'x86_64-w64-mingw32-objdump'
+
+[host_machine]
+system = 'windows'
+cpu_family = 'x86_64'
+cpu = 'native'
+endian = 'little'

0 comments on commit caf78ee

Please sign in to comment.