Skip to content

Commit

Permalink
Modify build version.
Browse files Browse the repository at this point in the history
  • Loading branch information
siriume committed Nov 21, 2024
1 parent 3ca3ec4 commit 791cf7c
Show file tree
Hide file tree
Showing 14 changed files with 209 additions and 18 deletions.
30 changes: 24 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ on:
default: false
required: false
schedule:
- cron: '0 12 * * *'
- cron: '00 17 * * *'

env:
DOCKER_BUILDKIT: 1
Expand All @@ -31,7 +31,7 @@ jobs:
steps:
- name: Repo Check
run: |
if [[ "$GITHUB_REPOSITORY" != "BtbN/FFmpeg-Builds" ]]; then
if [[ "$GITHUB_REPOSITORY" != "siriume/FFmpeg-Builds" ]]; then
echo "When forking this repository to make your own builds, you have to adjust this check."
echo "When doing so make sure to randomize the scheduled cron time above, in order to spread out the various build times as much as possible."
echo "This has been put in place due to the enormous amounts of traffic hundreds/thousands of parallel builds can cause on external infrastructure."
Expand Down Expand Up @@ -165,8 +165,17 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [win64,linux64,linuxarm64]
variant: [gpl,lgpl,gpl 5.1,gpl 6.1,gpl 7.1,lgpl 5.1,lgpl 6.1,lgpl 7.1,gpl-shared,lgpl-shared,gpl-shared 5.1,gpl-shared 6.1,gpl-shared 7.1,lgpl-shared 5.1,lgpl-shared 6.1,lgpl-shared 7.1]
target: [win64,linux64]
variant: [gpl,gpl 6.1,gpl 7.0,gpl 7.1,gpl-shared,gpl-shared 6.1,gpl-shared 7.0,gpl-shared 7.1]
include:
- target: linuxarm64
variant: gpl
- target: linuxarm64
variant: gpl 7.1
- target: linuxarm64
variant: gpl-shared
- target: linuxarm64
variant: gpl-shared 7.1
steps:
- name: Free Disk-Space
run: df -h && sudo apt-get clean && docker system prune -a -f && sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc && df -h
Expand Down Expand Up @@ -230,8 +239,17 @@ jobs:
strategy:
fail-fast: false
matrix:
target: [win64,linux64,linuxarm64]
variant: [gpl,lgpl,gpl 5.1,gpl 6.1,gpl 7.1,lgpl 5.1,lgpl 6.1,lgpl 7.1,gpl-shared,lgpl-shared,gpl-shared 5.1,gpl-shared 6.1,gpl-shared 7.1,lgpl-shared 5.1,lgpl-shared 6.1,lgpl-shared 7.1]
target: [win64,linux64]
variant: [gpl,gpl 6.1,gpl 7.0,gpl 7.1,gpl-shared,gpl-shared 6.1,gpl-shared 7.0,gpl-shared 7.1]
include:
- target: linuxarm64
variant: gpl
- target: linuxarm64
variant: gpl 7.1
- target: linuxarm64
variant: gpl-shared
- target: linuxarm64
variant: gpl-shared 7.1
steps:
- name: Free Disk-Space
run: df -h && sudo apt-get clean && docker system prune -a -f && sudo rm -rf /usr/local/lib/android /usr/share/dotnet /opt/ghc && df -h
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
fail-fast: false
matrix:
target: [win64,linux64,linuxarm64]
variant: [lgpl,gpl 6.1,gpl 5.1,lgpl 6.1,lgpl 5.1,gpl-shared,lgpl-shared,gpl-shared 6.1,gpl-shared 5.1,lgpl-shared 6.1,lgpl-shared 5.1]
variant: [gpl 6.1,gpl 5.1,gpl-shared,gpl-shared 6.1,gpl-shared 5.1]
quickbuild: [1]
include:
- target: win64
Expand Down
15 changes: 15 additions & 0 deletions .github/workflows/rebase-on-upstream.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Rebase on Upstream

on:
schedule:
- cron: "00 16 * * *" # run every day an hour before regular build
workflow_dispatch: # run manually

jobs:
rebase:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
with:
fetch-depth: 0
- uses: siriume/rebase-upstream-action@master
30 changes: 26 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ On success, the resulting zip file will be in the `artifacts` subdir.

Available targets:
* `win64` (x86_64 Windows)
* `win32` (x86 Windows)
* `linux64` (x86_64 Linux, glibc>=2.28, linux>=4.18)
* `linuxarm64` (arm64 (aarch64) Linux, glibc>=2.28, linux>=4.18)

Expand All @@ -58,11 +57,34 @@ Available variants:
* `gpl` Includes all dependencies, even those that require full GPL instead of just LGPL.
* `lgpl` Lacking libraries that are GPL-only. Most prominently libx264 and libx265.
* `nonfree` Includes fdk-aac in addition to all the dependencies of the gpl variant.
* `gpl-shared` Same as gpl, but comes with the libav* family of shared libs instead of pure static executables.
* `lgpl-shared` Same again, but with the lgpl set of dependencies.
* `nonfree-shared` Same again, but with the nonfree set of dependencies.

All of those can be optionally combined with any combination of addins:
* `4.4`/`5.0`/`5.1`/`6.0`/`6.1`/`7.0` to build from the respective release branch instead of master.
* `6.1`/`7.0`/`7.1` to build from the respective release branch instead of master.
* `debug` to not strip debug symbols from the binaries. This increases the output size by about 250MB.
* `lto` build all dependencies and ffmpeg with -flto=auto (HIGHLY EXPERIMENTAL, broken for Windows, sometimes works for Linux)


## Patches Applied
These patches have been applied to the builds:

### 1. Decoding non-standard HEVC in FLV containers

HEVC inside FLV has been [standardized](https://github.com/veovera/enhanced-rtmp/blob/8c51d437e20a9199d92f24d9950b1216e07f065f/enhanced-rtmp.pdf) by [@Veovera](https://github.com/veovera), implemented by [@T-bagwell](https://github.com/T-bagwell) and merged to FFmpeg master in [aa83654](https://github.com/FFmpeg/FFmpeg/commit/aa83654d940e7599ee641fc5d0fcd10e7decf277) and [ac5cc66](https://github.com/FFmpeg/FFmpeg/commit/ac5cc66f9e4408c45c303f6bf482ff04d7cb355e).

Chinese sites seem to continue using an old non-standard way to deliver HEVC in FLV containers. These builds of FFmpeg support the decoding of such files.

Releases older than 6.1 also supported the encoding of such non-standard files. The implementation was assembled from patches by [@xiaoxial](https://github.com/VCDP/CDN/blob/master/FFmpeg_patches/0001-Add-SVT-HEVC-FLV-support-on-FFmpeg.patch), [@runner365](https://github.com/runner365/ffmpeg_rtmp_h265/blob/5.1/flvenc.c), and [Matthieu Patou](https://patchwork.ffmpeg.org/project/ffmpeg/patch/[email protected]/).
See [this comment](https://github.com/yt-dlp/yt-dlp/pull/5823#issuecomment-1366868753) for details.

Fixes [yt-dlp#5874](https://github.com/yt-dlp/yt-dlp/issues/5874), [FFmpeg#6389](https://trac.ffmpeg.org/ticket/6389).

## Credits

* [@BtbN](https://github.com/BtbN) for the [original workflow](https://github.com/BtbN/FFmpeg-Builds)
* [@nihil-admirari](https://github.com/nihil-admirari) for creating and maintaining this repo
* [@yt-dlp](https://github.com/yt-dlp) for the [modified workflow](https://github.com/yt-dlp/FFmpeg-Builds)

---

PS: The commits are unsigned because of the periodic [automatic rebase](https://github.com/yt-dlp/FFmpeg-Builds/actions/workflows/rebase-on-upstream.yml)
15 changes: 14 additions & 1 deletion build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,25 @@ trap "rm -f -- '$BUILD_SCRIPT'" EXIT

cat <<EOF >"$BUILD_SCRIPT"
set -xe
shopt -s nullglob
cd /ffbuild
rm -rf ffmpeg prefix
git clone --filter=blob:none --branch='$GIT_BRANCH' '$FFMPEG_REPO' ffmpeg
cd ffmpeg
git config user.email "builder@localhost"
git config user.name "Builder"
PATCHES=('/patches/$GIT_BRANCH'/*.patch)
if [[ "\${#PATCHES[@]}" = 0 ]]; then
echo 'No patches found for $GIT_BRANCH'
fi
for patch in "\${PATCHES[@]}"; do
echo "Applying \$patch"
git apply "\$patch"
done
./configure --prefix=/ffbuild/prefix --pkg-config-flags="--static" \$FFBUILD_TARGET_FLAGS \$FF_CONFIGURE \
--extra-cflags="\$FF_CFLAGS" --extra-cxxflags="\$FF_CXXFLAGS" --extra-libs="\$FF_LIBS" \
--extra-ldflags="\$FF_LDFLAGS" --extra-ldexeflags="\$FF_LDEXEFLAGS" \
Expand All @@ -46,7 +59,7 @@ EOF

[[ -t 1 ]] && TTY_ARG="-t" || TTY_ARG=""

docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v "$PWD/ffbuild":/ffbuild -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh
docker run --rm -i $TTY_ARG "${UIDARGS[@]}" -v "$PWD/ffbuild":/ffbuild -v "$PWD/patches/ffmpeg/":/patches -v "$BUILD_SCRIPT":/build.sh "$IMAGE" bash /build.sh

mkdir -p artifacts
ARTIFACTS_PATH="$PWD/artifacts"
Expand Down
2 changes: 1 addition & 1 deletion images/base-linux64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
ARG GH_REPO=ghcr.io/siriume/ffmpeg-builds
FROM $GH_REPO/base:latest

RUN --mount=src=ct-ng-config,dst=/.config \
Expand Down
2 changes: 1 addition & 1 deletion images/base-linuxarm64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
ARG GH_REPO=ghcr.io/siriume/ffmpeg-builds
FROM $GH_REPO/base:latest

RUN --mount=src=ct-ng-config,dst=/.config \
Expand Down
2 changes: 1 addition & 1 deletion images/base-win32/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
ARG GH_REPO=ghcr.io/siriume/ffmpeg-builds
FROM $GH_REPO/base:latest

RUN --mount=src=ct-ng-config,dst=/.config \
Expand Down
2 changes: 1 addition & 1 deletion images/base-win64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
ARG GH_REPO=ghcr.io/siriume/ffmpeg-builds
FROM $GH_REPO/base:latest

RUN --mount=src=ct-ng-config,dst=/.config \
Expand Down
2 changes: 1 addition & 1 deletion images/base-winarm64/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ARG GH_REPO=ghcr.io/btbn/ffmpeg-builds
ARG GH_REPO=ghcr.io/siriume/ffmpeg-builds
FROM $GH_REPO/base:latest

RUN \
Expand Down
41 changes: 41 additions & 0 deletions patches/ffmpeg/master/0001-Nonstandard-HEVC-over-FLV.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/libavformat/flv.h b/libavformat/flv.h
index f710963..62297ed 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -116,6 +116,7 @@ enum {
FLV_CODECID_H264 = 7,
FLV_CODECID_REALH263= 8,
FLV_CODECID_MPEG4 = 9,
+ FLV_CODECID_HEVC = 12,
};

enum {
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 22a9b9e..dfbdaa6 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -335,6 +335,7 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
+ case FLV_CODECID_HEVC:
return vpar->codec_id == AV_CODEC_ID_HEVC;
case MKBETAG('a', 'v', '0', '1'):
return vpar->codec_id == AV_CODEC_ID_AV1;
@@ -367,6 +368,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
+ case FLV_CODECID_HEVC:
par->codec_id = AV_CODEC_ID_HEVC;
vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
break;
@@ -1463,7 +1465,7 @@ retry_duration:
}

if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) {
+ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) {
// sign extension
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
pts = av_sat_add64(dts, cts);
41 changes: 41 additions & 0 deletions patches/ffmpeg/release/7.0/0001-Nonstandard-HEVC-over-FLV.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/libavformat/flv.h b/libavformat/flv.h
index f710963..62297ed 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -116,6 +116,7 @@ enum {
FLV_CODECID_H264 = 7,
FLV_CODECID_REALH263= 8,
FLV_CODECID_MPEG4 = 9,
+ FLV_CODECID_HEVC = 12,
};

enum {
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 22a9b9e..dfbdaa6 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -335,6 +335,7 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
+ case FLV_CODECID_HEVC:
return vpar->codec_id == AV_CODEC_ID_HEVC;
case MKBETAG('a', 'v', '0', '1'):
return vpar->codec_id == AV_CODEC_ID_AV1;
@@ -367,6 +368,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
+ case FLV_CODECID_HEVC:
par->codec_id = AV_CODEC_ID_HEVC;
vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
break;
@@ -1463,7 +1465,7 @@ retry_duration:
}

if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) {
+ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) {
// sign extension
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
pts = av_sat_add64(dts, cts);
41 changes: 41 additions & 0 deletions patches/ffmpeg/release/7.1/0001-Nonstandard-HEVC-over-FLV.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
diff --git a/libavformat/flv.h b/libavformat/flv.h
index f710963..62297ed 100644
--- a/libavformat/flv.h
+++ b/libavformat/flv.h
@@ -116,6 +116,7 @@ enum {
FLV_CODECID_H264 = 7,
FLV_CODECID_REALH263= 8,
FLV_CODECID_MPEG4 = 9,
+ FLV_CODECID_HEVC = 12,
};

enum {
diff --git a/libavformat/flvdec.c b/libavformat/flvdec.c
index 22a9b9e..dfbdaa6 100644
--- a/libavformat/flvdec.c
+++ b/libavformat/flvdec.c
@@ -335,6 +335,7 @@ static int flv_same_video_codec(AVCodecParameters *vpar, uint32_t flv_codecid)

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
+ case FLV_CODECID_HEVC:
return vpar->codec_id == AV_CODEC_ID_HEVC;
case MKBETAG('a', 'v', '0', '1'):
return vpar->codec_id == AV_CODEC_ID_AV1;
@@ -367,6 +368,7 @@ static int flv_set_video_codec(AVFormatContext *s, AVStream *vstream,

switch (flv_codecid) {
case MKBETAG('h', 'v', 'c', '1'):
+ case FLV_CODECID_HEVC:
par->codec_id = AV_CODEC_ID_HEVC;
vstreami->need_parsing = AVSTREAM_PARSE_HEADERS;
break;
@@ -1463,7 +1465,7 @@ retry_duration:
}

if (st->codecpar->codec_id == AV_CODEC_ID_H264 || st->codecpar->codec_id == AV_CODEC_ID_MPEG4 ||
- (st->codecpar->codec_id == AV_CODEC_ID_HEVC && type == PacketTypeCodedFrames)) {
+ (st->codecpar->codec_id == AV_CODEC_ID_HEVC && (!enhanced_flv || type == PacketTypeCodedFrames))) {
// sign extension
int32_t cts = (avio_rb24(s->pb) + 0xff800000) ^ 0xff800000;
pts = av_sat_add64(dts, cts);
2 changes: 1 addition & 1 deletion util/vars.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ while [[ "$#" -gt 0 ]]; do
shift
done

REPO="${GITHUB_REPOSITORY:-btbn/ffmpeg-builds}"
REPO="${GITHUB_REPOSITORY:-siriume/ffmpeg-builds}"
REPO="${REPO,,}"
REGISTRY="${REGISTRY_OVERRIDE:-ghcr.io}"
BASE_IMAGE="${REGISTRY}/${REPO}/base:latest"
Expand Down

0 comments on commit 791cf7c

Please sign in to comment.