Skip to content

Commit cd409ab

Browse files
committed
feat(ffmpeg8): decouple ffmpeg8-bin program compilation and enforce macos exclusivity
1 parent 2ec8b4e commit cd409ab

13 files changed

Lines changed: 160 additions & 50 deletions

File tree

.github/workflows/build all libs.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ on:
6363
- ffmpeg6
6464
- ffmpeg7
6565
- ffmpeg8
66+
- ffmpeg8-bin
6667
dryrun:
6768
description: 'just run workflow,but not deploy'
6869
required: false
@@ -214,6 +215,7 @@ jobs:
214215
"ffmpeg6"
215216
"ffmpeg7"
216217
"ffmpeg8"
218+
"ffmpeg8-bin"
217219
)
218220
219221
first=${{ inputs.first_library }}

.github/workflows/build one lib.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ on:
5050
default: 'ffmpeg7'
5151
options:
5252
- ffmpeg8
53+
- ffmpeg8-bin
5354
- ffmpeg7
5455
- ffmpeg6
5556
- ffmpeg5

.github/workflows/install-dependencies.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ case $LIB_NAME in
5454
fi
5555
fi
5656
;;
57+
ffmpeg8-bin)
58+
./main.sh install -l 'ass openssl3 opus bluray dav1d dvdnav uavs3d smb2 webp x264 x265' -p macos
59+
;;
5760
ffmpeg7)
5861
if [[ $PLAT == all ]];then
5962
./main.sh install -l 'openssl3 opus bluray dav1d dvdnav uavs3d smb2 webp' -p ios

.github/workflows/onestep.sh

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ fi
2525
export HOMEBREW_NO_AUTO_UPDATE=1
2626
export RELEASE_DATE=$(TZ=UTC-8 date +'%y%m%d%H%M%S')
2727
export RELEASE_VERSION=$(grep GIT_REPO_VERSION= ./configs/libs/${LIB_NAME}.sh | tail -n 1 | awk -F = '{printf "%s",$2}')
28+
export REPO_DIR=$(grep REPO_DIR= ./configs/libs/${LIB_NAME}.sh | tail -n 1 | awk -F = '{printf "%s",$2}' | tr -d "'\"")
2829
export TAG=${LIB_NAME}-${RELEASE_VERSION}-${RELEASE_DATE}
2930
export TITLE="👏👏${LIB_NAME}-${PLAT}-${RELEASE_VERSION}"
3031

@@ -70,11 +71,7 @@ function compile_macos_platform
7071

7172
local log_file="$DIST_DIR/macos-compile-log-$RELEASE_VERSION.md"
7273

73-
local repo_dir=$(grep REPO_DIR= ./configs/libs/${LIB_NAME}.sh | tail -n 1 | awk -F = '{printf "%s",$2}' | tr -d '"'\''')
7474
local extra_args=""
75-
if [[ "$repo_dir" == "ffmpeg8" ]]; then
76-
extra_args="--enable-ffmpeg"
77-
fi
7875

7976
if [[ $VERBOSE ]];then
8077
./main.sh compile -p macos -c build -l ${LIB_NAME} $extra_args 2>&1 | tee -a "$log_file"
@@ -86,14 +83,16 @@ function compile_macos_platform
8683
zip -ryq $DIST_DIR/${LIB_NAME}-macos-universal-${RELEASE_VERSION}.zip ./*
8784
cd $ROOT_DIR
8885

89-
# Copy the architecture-specific ffmpeg binaries if they were compiled
90-
if [[ "$repo_dir" == "ffmpeg8" ]]; then
86+
# Copy the architecture-specific binaries if they were compiled
87+
if [[ "$REPO_DIR" == "ffmpeg8" ]]; then
9188
for arch in arm64 x86_64; do
92-
local ffmpeg_bin="build/product/macos/${LIB_NAME}-${arch}/bin/ffmpeg"
93-
if [ -f "$ffmpeg_bin" ]; then
94-
cp "$ffmpeg_bin" "$DIST_DIR/ffmpeg-macos-${arch}"
95-
echo "Copied $ffmpeg_bin to $DIST_DIR/ffmpeg-macos-${arch}"
96-
fi
89+
for bin in ffmpeg ffplay ffprobe; do
90+
local bin_file="build/product/macos/${LIB_NAME}-${arch}/bin/$bin"
91+
if [ -f "$bin_file" ]; then
92+
cp "$bin_file" "$DIST_DIR/$bin-macos-${arch}"
93+
echo "Copied $bin_file to $DIST_DIR/$bin-macos-${arch}"
94+
fi
95+
done
9796
done
9897
fi
9998
}

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,5 @@ If cloning repositories from GitHub is slow, or if you need to use an internal p
158158

159159
- To download pre-compiled xcframework libraries, add the --fmwk parameter when using the install command.
160160
- To skip pulling remote repositories during initialization, add the --skip-pull-base parameter when using the init command.
161-
- To compile the `ffmpeg` command-line program itself alongside the macOS libraries (with VideoToolbox encoders and lavfi indevs enabled), add the `--enable-ffmpeg` parameter.
162161
- Currently, FFmpeg uses the **module-full.sh** configuration, resulting in slightly larger package sizes.
163162
- You can download all pre-compiled GitHub libraries to your own server and specify your server address using MR\_DOWNLOAD\_BASEURL before running the install command.

README_zh-CN.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,5 @@ MRFFToolChain 是一套成熟的编译工具,专门用来编译 iOS、macOS、
161161

162162
- 要下载预编译的 xcframework 库,使用 install 命令时添加 --fmwk 参数
163163
- 初始化时要跳过拉取远程仓库,使用 init 命令时添加 --skip-pull-base 参数
164-
- 编译 macOS 平台时可同时生成 `ffmpeg` 可执行程序(并启用 VideoToolbox 编码器和 lavfi 输入设备),使用 compile 命令时添加 `--enable-ffmpeg`
165164
- 目前 FFmpeg 使用 module-full.sh 配置,功能全但同时导致包体积略大
166165
- 可以将所有预编译的 GitHub 库下载到自己的服务器,并在运行 install 命令前通过 MR\_DOWNLOAD\_BASEURL 指定你的服务器地址

configs/ffconfig/module-full.sh

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,8 @@ export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-gray"
1919
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-swscale-alpha"
2020

2121
# Program options:
22-
if [[ "$MR_ENABLE_FFMPEG" == "1" ]]; then
23-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-ffmpeg"
24-
else
25-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-programs"
26-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffmpeg"
27-
fi
22+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-programs"
23+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffmpeg"
2824
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffplay"
2925
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-ffprobe"
3026
#ff4.0--ijk0.8.25--20190703--001 Unknown option "--disable-ffserver"
@@ -86,12 +82,6 @@ export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-encoders"
8682
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=wmv*"
8783
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=msmpeg4*"
8884
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=gif"
89-
if [[ "$MR_ENABLE_FFMPEG" == "1" ]]; then
90-
# 显式启用 VideoToolbox hevc(H.265) 编码器
91-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=hevc_videotoolbox"
92-
# 显式启用 VideoToolbox H.264 编码器
93-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=h264_videotoolbox"
94-
fi
9585
# ./configure --list-decoders
9686
#audio
9787
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-decoders"
@@ -450,9 +440,7 @@ export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-protocol=unix"
450440

451441
#
452442
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-devices"
453-
if [[ "$MR_ENABLE_FFMPEG" == "1" ]]; then
454-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-indev=lavfi,testsrc,sine"
455-
fi
443+
# export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-indev=lavfi,testsrc,sine"
456444
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-filters"
457445
# transpose_vt available macos(13.0), ios(16.0), tvos(16.0), visionos(1.0)
458446
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --disable-filter=transpose_vt"

configs/ffconfig/module-program.sh

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,16 @@ cd ${enter_path}
1313
# enable programs
1414
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-avdevice"
1515
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-avfilter"
16-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-sdl2"
1716
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-ffmpeg"
1817
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-ffplay"
19-
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-ffprobe"
18+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-ffprobe"
19+
20+
# enable virtual and capture indevs for the binary program
21+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-indev=lavfi,testsrc,sine"
22+
if [[ "$MR_PLAT" == "macos" || "$MR_PLAT" == "ios" ]]; then
23+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-indev=avfoundation,openal"
24+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-outdev=audiotoolbox"
25+
# 显式启用 VideoToolbox hevc(H.265) 与 H.264 硬件加速编码器
26+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=hevc_videotoolbox"
27+
export COMMON_FF_CFG_FLAGS="$COMMON_FF_CFG_FLAGS --enable-encoder=h264_videotoolbox"
28+
fi

configs/libs/ffmpeg8-bin.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export LIB_NAME='ffmpeg8-bin'
2+
3+
if [[ "$MR_PLAT" != "macos" ]]; then
4+
echo "❌ ffmpeg8-bin is only supported on the macos platform."
5+
exit 1
6+
fi
7+
8+
export LIPO_LIBS=""
9+
export LIB_DEPENDS_BIN="nasm pkg-config"
10+
export GIT_LOCAL_REPO=extra/ffmpeg
11+
export REPO_DIR=ffmpeg8
12+
export PATCH_DIR=../../patches/ffmpeg8-bin
13+
export GIT_COMMIT=n8.1.2
14+
export GIT_REPO_VERSION=8.1.2
15+
16+
if [[ "$GIT_FFMPEG_UPSTREAM" != "" ]] ;then
17+
export GIT_UPSTREAM="$GIT_FFMPEG_UPSTREAM"
18+
else
19+
export GIT_UPSTREAM=https://github.com/FFmpeg/FFmpeg.git
20+
fi

do-compile/apple/ffmpeg.sh

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -39,21 +39,7 @@ CFG_FLAGS="$CFG_FLAGS $COMMON_FF_CFG_FLAGS"
3939
CFG_FLAGS="$CFG_FLAGS $THIRD_CFG_FLAGS"
4040

4141
C_FLAGS="$MR_DEFAULT_CFLAGS"
42-
EXTRA_LDFLAGS=
43-
if [[ "$MR_ENABLE_FFMPEG" == "1" && "$MR_PLAT" = "macos" ]]; then
44-
# Dynamically find third-party static libraries using pkg-config
45-
pkgs="libass libbluray dav1d dvdread dvdnav freetype2 fribidi harfbuzz openssl opus libsmb2 uavs3d libunibreak libxml-2.0 libwebp libwebpdecoder libwebpdemux"
46-
enabled_pkgs=""
47-
for pkg in $pkgs; do
48-
if pkg-config --exists "$pkg" 2>/dev/null; then
49-
enabled_pkgs="$enabled_pkgs $pkg"
50-
fi
51-
done
52-
if [ -n "$enabled_pkgs" ]; then
53-
EXTRA_LDFLAGS=$(pkg-config --static --libs $enabled_pkgs)
54-
fi
55-
fi
56-
LDFLAGS="$C_FLAGS $EXTRA_LDFLAGS"
42+
LDFLAGS="$C_FLAGS"
5743
# C_FLAGS="$C_FLAGS -I/Users/matt/GitWorkspace/MoltenVK/Package/Release/MoltenVK/include"
5844
# use system xml2 lib
5945
# C_FLAGS="$C_FLAGS $(xml2-config --prefix=${MR_SYS_ROOT}/usr --cflags)"

0 commit comments

Comments
 (0)