프로젝트 소스 공개
This commit is contained in:
Executable
+96
@@ -0,0 +1,96 @@
|
||||
#!/bin/bash
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIRECTORY="$(cd "$(dirname "$0")" && pwd)"
|
||||
PROJECT_ROOT="$(cd "$SCRIPT_DIRECTORY/.." && pwd)"
|
||||
FFMPEG_ROOT="$PROJECT_ROOT/ThirdParty/FFmpeg"
|
||||
SOURCE_ARCHIVE="$FFMPEG_ROOT/Source/ffmpeg-8.1.2.tar.xz"
|
||||
OUTPUT_BINARY="$FFMPEG_ROOT/macOS/ffmpeg"
|
||||
EXPECTED_SHA256="464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c"
|
||||
BUILD_ROOT="$(mktemp -d /tmp/projectquint-ffmpeg-build.XXXXXX)"
|
||||
BUILD_JOBS="$(sysctl -n hw.ncpu)"
|
||||
|
||||
cleanup() {
|
||||
rm -rf "$BUILD_ROOT"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [[ ! -f "$SOURCE_ARCHIVE" ]]; then
|
||||
echo "Missing pinned source archive: $SOURCE_ARCHIVE" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ACTUAL_SHA256="$(shasum -a 256 "$SOURCE_ARCHIVE" | awk '{print $1}')"
|
||||
if [[ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]]; then
|
||||
echo "FFmpeg source hash mismatch: $ACTUAL_SHA256" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
tar -xf "$SOURCE_ARCHIVE" -C "$BUILD_ROOT"
|
||||
SOURCE_ROOT="$BUILD_ROOT/ffmpeg-8.1.2"
|
||||
|
||||
COMMON_OPTIONS=(
|
||||
--target-os=darwin
|
||||
--cc=clang
|
||||
--disable-everything
|
||||
--disable-autodetect
|
||||
--disable-doc
|
||||
--disable-debug
|
||||
--disable-network
|
||||
--disable-x86asm
|
||||
--enable-small
|
||||
--enable-ffmpeg
|
||||
--disable-ffprobe
|
||||
--disable-ffplay
|
||||
--enable-avcodec
|
||||
--enable-avformat
|
||||
--enable-avfilter
|
||||
--enable-swscale
|
||||
--enable-protocol=file
|
||||
--enable-demuxer=asf,avi
|
||||
--enable-decoder=wmv1,wmv2,wmv3,vc1,mpeg4,msmpeg4v1,msmpeg4v2,msmpeg4v3,mjpeg,h263,h264,rawvideo
|
||||
--enable-parser=vc1,mpeg4video,mjpeg,h263,h264
|
||||
--enable-encoder=h264_videotoolbox
|
||||
--enable-muxer=mp4
|
||||
--enable-filter=format,scale
|
||||
--enable-videotoolbox
|
||||
)
|
||||
|
||||
build_architecture() {
|
||||
local architecture="$1"
|
||||
local build_directory="$BUILD_ROOT/build-$architecture"
|
||||
local install_directory="$BUILD_ROOT/install-$architecture"
|
||||
mkdir -p "$build_directory" "$install_directory"
|
||||
(
|
||||
cd "$build_directory"
|
||||
"$SOURCE_ROOT/configure" \
|
||||
"--prefix=$install_directory" \
|
||||
"--arch=$architecture" \
|
||||
"--extra-cflags=-arch $architecture -mmacosx-version-min=12.0" \
|
||||
"--extra-ldflags=-arch $architecture -mmacosx-version-min=12.0" \
|
||||
"${COMMON_OPTIONS[@]}"
|
||||
make -j"$BUILD_JOBS"
|
||||
make install
|
||||
)
|
||||
}
|
||||
|
||||
build_architecture arm64
|
||||
build_architecture x86_64
|
||||
|
||||
mkdir -p "$(dirname "$OUTPUT_BINARY")"
|
||||
lipo -create \
|
||||
"$BUILD_ROOT/install-arm64/bin/ffmpeg" \
|
||||
"$BUILD_ROOT/install-x86_64/bin/ffmpeg" \
|
||||
-output "$OUTPUT_BINARY"
|
||||
chmod 755 "$OUTPUT_BINARY"
|
||||
lipo "$OUTPUT_BINARY" -verify_arch arm64 x86_64
|
||||
|
||||
VERSION_OUTPUT="$($OUTPUT_BINARY -version)"
|
||||
if [[ "$VERSION_OUTPUT" == *"--enable-gpl"* ||
|
||||
"$VERSION_OUTPUT" == *"--enable-nonfree"* ||
|
||||
"$VERSION_OUTPUT" == *"libx264"* ]]; then
|
||||
echo "Refusing non-LGPL FFmpeg configuration." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "Built Universal LGPL FFmpeg: $OUTPUT_BINARY"
|
||||
Reference in New Issue
Block a user