Enable AMD AMF in Windows ChatGUI FFmpeg build

This commit is contained in:
evgeny committed 2026-10-16 18:50:42 +02:00
1 parent 5116496565
commit f90cbae94a
1 file changed
+37 -2
+37 -2
View File
@@ -6,6 +6,8 @@ BUILD_DIR="$SCRIPT_DIR/ffmpeg_build"
SRC_DIR="$BUILD_DIR/src"
INSTALL_DIR="$BUILD_DIR/install"
JOBS=$(nproc 2>/dev/null || echo 4)
AMF_HEADERS_VERSION="${AMF_HEADERS_VERSION:-1.5.3}"
AMF_MARKER="$INSTALL_DIR/share/utun-ffmpeg-amf-enabled"
case "$(uname -s)" in
Linux) PLATFORM=linux ;;
@@ -62,6 +64,7 @@ check_cmd nasm
check_cmd pkg-config
check_cmd meson
check_cmd git
check_cmd curl
# ============================================================================
# Step 1: Codec libraries (static .a, built with -fPIC)
@@ -202,7 +205,26 @@ fi
# ============================================================================
# Step 2: FFmpeg
# ============================================================================
if [ -f "$INSTALL_DIR/lib/pkgconfig/libavcodec.pc" ]; then
if [ "$PLATFORM" = "windows" ] && [ ! -f "$INSTALL_DIR/include/AMF/core/Factory.h" ]; then
AMF_ARCHIVE="$SRC_DIR/AMF-headers-v$AMF_HEADERS_VERSION.tar.gz"
AMF_EXTRACT_DIR="$SRC_DIR/amf-headers-$AMF_HEADERS_VERSION"
mkdir -p "$AMF_EXTRACT_DIR" "$INSTALL_DIR/include/AMF"
if [ ! -f "$AMF_ARCHIVE" ]; then
log "Download AMD AMF headers v$AMF_HEADERS_VERSION..."
curl -fL --retry 3 -o "$AMF_ARCHIVE" \
"https://github.com/GPUOpen-LibrariesAndSDKs/AMF/releases/download/v$AMF_HEADERS_VERSION/AMF-headers-v$AMF_HEADERS_VERSION.tar.gz"
fi
log "Extract AMD AMF headers..."
tar -xzf "$AMF_ARCHIVE" -C "$AMF_EXTRACT_DIR"
AMF_FACTORY_HEADER=$(find "$AMF_EXTRACT_DIR" -type f -path '*/AMF/core/Factory.h' -print -quit)
[ -n "$AMF_FACTORY_HEADER" ] || die "AMF headers archive does not contain AMF/core/Factory.h"
AMF_HEADER_ROOT="${AMF_FACTORY_HEADER%/AMF/core/Factory.h}"
cp -a "$AMF_HEADER_ROOT/AMF/." "$INSTALL_DIR/include/AMF/"
log "AMD AMF headers installed in $INSTALL_DIR/include/AMF"
fi
if [ -f "$INSTALL_DIR/lib/pkgconfig/libavcodec.pc" ] \
&& { [ "$PLATFORM" != "windows" ] || [ -f "$AMF_MARKER" ]; }; then
log "FFmpeg already built, skipping."
log "Done: $INSTALL_DIR"
exit 0
@@ -252,16 +274,29 @@ CONFIGURE_ARGS=(
if [ "$PLATFORM" = "windows" ]; then
CONFIGURE_ARGS+=(
--enable-d3d11va --enable-dxva2
--enable-d3d11va --enable-dxva2 --enable-amf
)
fi
"./configure" "${CONFIGURE_ARGS[@]}"
if [ "$PLATFORM" = "windows" ]; then
for encoder in CONFIG_H264_AMF_ENCODER CONFIG_HEVC_AMF_ENCODER; do
grep -Eq "^#define $encoder 1$" config_components.h \
|| die "FFmpeg configure did not enable $encoder; check AMF headers and config.log"
done
rm -f "$AMF_MARKER"
fi
log "Build FFmpeg..."
make -j"$JOBS"
make install
if [ "$PLATFORM" = "windows" ]; then
mkdir -p "$(dirname "$AMF_MARKER")"
touch "$AMF_MARKER"
fi
log "==============================================================="
log "FFmpeg build SUCCESS"
log "Install prefix: $INSTALL_DIR"