Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@Brooooooklyn
Copy link
Owner

@Brooooooklyn Brooooooklyn commented Jan 1, 2026

  • Add -DENABLE_ALPHA=ON to x265 CMake builds in tools/build-ffmpeg
  • Add x265 multi-lib build (8/10/12-bit) to macOS static libs workflow
  • macOS x265 is built from source to bypass Homebrew (which lacks alpha)

This enables HEVC alpha channel encoding support across all 9 platforms.



🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.5 [email protected]


Note

Enables HEVC alpha channel support end-to-end by building and integrating x265 with alpha across all targets.

  • Add -DENABLE_ALPHA=ON to x265 CMake args in tools/build-ffmpeg and retain multilib combine step
  • Windows (x64/arm64): stop installing x265 via vcpkg; build x265 from source (8/10/12-bit), combine into single static lib, install headers/x265.pc, and link in FFmpeg builds
  • macOS static-libs (x86_64/arm64): add x265 multilib source build with alpha; package combined libx265.a and x265.pc alongside dav1d/libjxl deps
  • CI workflow updates in .github/workflows/ffmpeg-build.yml to reflect custom x265 builds, library copies, and pkg-config entries

Written by Cursor Bugbot for commit 23c3ff1. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings January 1, 2026 06:57
Copy link
Owner Author

Brooooooklyn commented Jan 1, 2026

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR enables HEVC alpha channel encoding support across all 9 platforms by adding the -DENABLE_ALPHA=ON flag to x265 CMake builds.

Key changes:

  • Added -DENABLE_ALPHA=ON flag to x265 builds in the build-ffmpeg tool
  • Implemented x265 multi-lib builds (8/10/12-bit) for macOS (x64 and arm64) static library workflows
  • macOS builds compile x265 from source to bypass Homebrew's lack of alpha support

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 7 comments.

File Description
tools/build-ffmpeg/src/main.rs Adds -DENABLE_ALPHA=ON flag to x265 CMake configuration for all platform builds
.github/workflows/ffmpeg-build.yml Adds complete x265 multi-lib build process for both macOS x64 and arm64 platforms, building 12-bit, 10-bit, and 8-bit libraries with alpha support and combining them into a unified static library

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copilot AI review requested due to automatic review settings January 1, 2026 07:43
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from 8bfbc3b to 1fb93c9 Compare January 1, 2026 07:51
Copilot AI review requested due to automatic review settings January 1, 2026 07:59
@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from 1fb93c9 to a03352f Compare January 1, 2026 07:59
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 12 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from a03352f to c320a28 Compare January 1, 2026 08:08
Copilot AI review requested due to automatic review settings January 1, 2026 08:58
@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from c320a28 to 116a89f Compare January 1, 2026 08:58
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 9 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Add `-DENABLE_ALPHA=ON` to x265 CMake builds in tools/build-ffmpeg
- Add x265 multi-lib build (8/10/12-bit) to macOS static libs workflow
- macOS x265 is built from source to bypass Homebrew (which lacks alpha)

This enables HEVC alpha channel encoding support across all 9 platforms.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from 116a89f to 5c0d734 Compare January 1, 2026 09:17
The issue: x265's CMakeLists.txt uses `git describe --abbrev=0 --tags`
to detect version, which requires a tag reachable from HEAD. With
shallow clone, even fetching the remote tag doesn't make it reachable
because the tag's commit isn't in the truncated history.

The fix: Create a local tag "4.1" at HEAD after cloning. This makes
`git describe` return "4.1", which the version parsing expects.

Root cause analysis:
- Version.cmake runs `git describe --abbrev=0 --tags`
- CMakeLists.txt:860-870 parses result with REGEX MATCHALL "([0-9]+)"
- Empty/invalid tag → empty VERSION_LIST → list(GET) fails

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 1, 2026 09:47
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

# x265 (HEVC encoder with alpha support)
# Build multi-lib x265 with ENABLE_ALPHA=ON for HEVC alpha encoding
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
cd x265_git/build
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS x265 builds missing git tag for version detection

The macOS x265 builds (both x64 and ARM64) are missing the git tag 4.1 command that the Windows builds explicitly include for version detection. With shallow clones using --depth 1 --branch Release_4.1, the tag isn't reachable from HEAD, causing git describe --abbrev=0 --tags to fail. The Windows builds include comments explaining this workaround, but the macOS builds skip directly to cd x265_git/build without creating the local tag. This could cause version detection failures or incorrect version strings in the built x265 libraries.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy-Item -Force build-main/x265_config.h "$VCPKG_INSTALLED/include/"
Write-Host "x265 with alpha support installed to $VCPKG_INSTALLED"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows x265 pkg-config reports wrong version after upgrade

The PR changes Windows x265 from vcpkg installation to building version 4.1 from source (Release_4.1 branch), but the pkg-config files still report version "3.5". The macOS builds correctly set "Version: 4.1" in their pkg-config files, but the Windows builds at lines 259 and 667 were not updated. This version mismatch could cause issues for downstream consumers that check pkg-config --modversion x265 for version compatibility, such as requiring version >= 4.0 for alpha channel support.

Additional Locations (1)

Fix in Cursor Fix in Web

# x265 (HEVC encoder with alpha support)
# Build multi-lib x265 with ENABLE_ALPHA=ON for HEVC alpha encoding
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
cd x265_git/build
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS x265 builds missing git tag for version detection

The macOS x265 builds are missing the git tag 4.1 command that the Windows builds include. The Windows builds have explicit comments explaining this tag is required because git describe --abbrev=0 --tags needs a tag reachable from HEAD, and shallow clones don't include the tag in history. Without creating this local tag, x265's version detection during CMake configure may fail or produce incorrect version information.

Additional Locations (1)

Fix in Cursor Fix in Web

Copy-Item -Force build-main/x265_config.h "$VCPKG_INSTALLED/include/"
Write-Host "x265 with alpha support installed to $VCPKG_INSTALLED"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

x265 pkg-config version mismatch after source build upgrade

The Windows builds create pkg-config files with x265 version "3.5", but this PR now builds x265 version 4.1 from source (using the Release_4.1 branch). The version strings in the create_pc calls for x265 weren't updated to match the actual library version being built. This version mismatch could cause issues if consuming software performs version checks.

Additional Locations (1)

Fix in Cursor Fix in Web

Copilot AI review requested due to automatic review settings January 1, 2026 13:08
@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from a590e44 to eaa7dd0 Compare January 1, 2026 13:08
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

'Description: H.265/HEVC video encoder with alpha support'
'Version: 4.1'
'Libs: -L${libdir} -lx265-static'
'Libs.private: -lstdc++'
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pkg-config file for Windows x64 uses -lstdc++ in Libs.private, but this is incorrect for Windows with MSVC/ClangCL toolchains which use the MSVC C++ runtime instead. This could cause linking failures when FFmpeg tries to link against x265. Consider removing Libs.private on Windows or using appropriate Windows C++ runtime flags.

Suggested change
'Libs.private: -lstdc++'

Copilot uses AI. Check for mistakes.
Comment on lines 156 to 174
cmake --build build-12bit --config Release --parallel
# Build 10-bit lib
cmake -B build-10bit -S source -G "Visual Studio 17 2022" -A ARM64 -T ClangCL `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
-DHIGH_BIT_DEPTH=ON `
-DEXPORT_C_API=OFF
cmake --build build-10bit --config Release --parallel
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cmake build commands use --parallel without specifying a job count. While this will use all available cores by default, it could cause resource exhaustion on CI runners with limited memory, especially when building multiple variants (12-bit, 10-bit, 8-bit) sequentially. Consider adding explicit job limits like --parallel 2 or using environment variables to control parallelism based on available resources.

Copilot uses AI. Check for mistakes.
Comment on lines +141 to +144
# Create a local tag for version detection
# git describe --abbrev=0 --tags needs a tag reachable from HEAD
# Shallow clone doesn't have the tag in history, so we create one locally
git tag 4.1
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows x265 build scripts clone a repository using --depth 1 which creates a shallow clone without tags. The script then creates a local tag 4.1, but this tag is never pushed and only exists locally in the CI environment. While this works for the immediate build, it creates an inconsistency where the tag only exists in the CI runner's temporary environment and doesn't reflect the actual repository state. Consider using git fetch --depth 1 origin refs/tags/Release_4.1:refs/tags/Release_4.1 instead to fetch the actual tag, or document why a local tag is necessary if git describe is being used internally by the x265 build system.

Suggested change
# Create a local tag for version detection
# git describe --abbrev=0 --tags needs a tag reachable from HEAD
# Shallow clone doesn't have the tag in history, so we create one locally
git tag 4.1
# Fetch the real Release_4.1 tag for version detection (e.g. via git describe)
git fetch --depth 1 origin refs/tags/Release_4.1:refs/tags/Release_4.1

Copilot uses AI. Check for mistakes.
Comment on lines +1146 to +1172
cp ../source/x265.h $PREFIX/include/ 2>/dev/null || true
cp build-main/x265_config.h $PREFIX/include/ 2>/dev/null || true
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The script copies header files with error suppression (2>/dev/null || true), which silently ignores failures. If these headers are critical for the build, the copy should fail loudly. If they're optional or already exist, this should be documented. Without proper error handling, a missing header file could cause cryptic build failures later in the FFmpeg compilation stage.

Suggested change
cp ../source/x265.h $PREFIX/include/ 2>/dev/null || true
cp build-main/x265_config.h $PREFIX/include/ 2>/dev/null || true
if [ -f ../source/x265.h ]; then
cp ../source/x265.h $PREFIX/include/
else
echo "Warning: x265.h not found; x265 development headers may be incomplete." >&2
fi
if [ -f build-main/x265_config.h ]; then
cp build-main/x265_config.h $PREFIX/include/
else
echo "Warning: x265_config.h not found; x265 configuration header will be missing." >&2
fi

Copilot uses AI. Check for mistakes.
Comment on lines +1330 to +1356
cp ../source/x265.h $PREFIX/include/ 2>/dev/null || true
cp build-main/x265_config.h $PREFIX/include/ 2>/dev/null || true
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same error suppression pattern (2>/dev/null || true) is used when copying header files in the macOS ARM64 build. This creates the same issue as in the x64 build where critical file copy failures could be silently ignored. Ensure these headers are either guaranteed to exist or handle their absence explicitly with proper error messages.

Suggested change
cp ../source/x265.h $PREFIX/include/ 2>/dev/null || true
cp build-main/x265_config.h $PREFIX/include/ 2>/dev/null || true
cp ../source/x265.h $PREFIX/include/
cp build-main/x265_config.h $PREFIX/include/

Copilot uses AI. Check for mistakes.
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/x64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This git clone operation has the same security concern as the Windows ARM64 build. The code is cloned from a branch without commit SHA verification or integrity checks. If the x265 repository or Release_4.1 branch were compromised, malicious code could be introduced into the build. Consider verifying the cloned code's integrity or pinning to a specific verified commit SHA.

Copilot uses AI. Check for mistakes.
# x265 (HEVC encoder with alpha support)
# Build multi-lib x265 with ENABLE_ALPHA=ON for HEVC alpha encoding
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This git clone operation lacks commit SHA verification or integrity checks, similar to the Windows builds. Consider pinning to a specific verified commit SHA or adding checksum verification to ensure the cloned source code hasn't been tampered with.

Copilot uses AI. Check for mistakes.
Comment on lines +549 to +570
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
cd x265_git
# Create a local tag for version detection
# git describe --abbrev=0 --tags needs a tag reachable from HEAD
# Shallow clone doesn't have the tag in history, so we create one locally
git tag 4.1
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Windows x64 build has the exact same local tag creation logic as the ARM64 build. The tag is created locally but never used or pushed. This is duplicated code that adds maintenance burden. If the tag is required for x265's version detection during the build, this should be documented. Otherwise, consider removing these tag creation steps or consolidate them into a reusable script.

Copilot uses AI. Check for mistakes.
'Description: H.265/HEVC video encoder with alpha support'
'Version: 4.1'
'Libs: -L${libdir} -lx265-static'
'Libs.private: -lstdc++'
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The pkg-config file for Windows uses -lstdc++ in Libs.private, but Windows with MSVC/ClangCL typically doesn't use libstdc++. Windows uses the MSVC C++ runtime (MSVCRT/UCRT) by default. This could cause linking issues when FFmpeg tries to use this pkg-config file. Consider removing Libs.private on Windows or using appropriate Windows C++ runtime flags if needed.

Suggested change
'Libs.private: -lstdc++'

Copilot uses AI. Check for mistakes.
'Description: H.265/HEVC video encoder with alpha support'
'Version: 4.1'
'Libs: -L${libdir} -lx265-static'
'Libs.private: -lstdc++'
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Windows pkg-config uses incompatible GCC library flag

The Windows x265 pkg-config files specify Libs.private: -lstdc++, but the builds use MSVC/ClangCL toolchain which doesn't have libstdc++. The -lstdc++ flag is a GCC/MinGW convention for the GNU C++ standard library. When FFmpeg uses pkg-config with --static, this would attempt to link a non-existent library. The macOS builds correctly use -lc++ for the Clang runtime. For MSVC, Libs.private could be empty since the C++ runtime is linked automatically, or removed entirely.

Additional Locations (1)

Fix in Cursor Fix in Web

@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from eaa7dd0 to 1d20eb6 Compare January 1, 2026 13:59
# x265 (HEVC encoder with alpha support)
# Build multi-lib x265 with ENABLE_ALPHA=ON for HEVC alpha encoding
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
cd x265_git/build
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macOS builds missing git tag for version detection

The macOS x265 builds (both x64 and arm64) are missing the git tag 4.1 command that exists in the Windows builds. The Windows builds include explicit comments explaining this step is necessary because shallow clones with --depth 1 don't include tags in the history, causing git describe --abbrev=0 --tags (used by x265's CMake for version detection) to fail. Without this step, the x265 build on macOS may produce incorrect version information in x265_config.h or encounter version detection failures.

Additional Locations (1)

Fix in Cursor Fix in Web

x265's ARM64 NEON intrinsics use GCC/Clang-specific syntax that MSVC
doesn't support:
- __attribute__((aligned(N))) vs __declspec(align(N))
- NEON vector brace initialization syntax differences
- uint16x8_t[N] array subscript not supported by MSVC's arm_neon.h

Adding -DENABLE_ASSEMBLY=OFF uses scalar C fallbacks instead of NEON
intrinsics. This is the same approach vcpkg uses for x265 on Windows ARM64.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <[email protected]>
Copilot AI review requested due to automatic review settings January 1, 2026 14:56
@Brooooooklyn Brooooooklyn force-pushed the feat/x265-alpha-build branch from 1d20eb6 to 23c3ff1 Compare January 1, 2026 14:56
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy-Item -Force source/x265.h "$VCPKG_INSTALLED/include/"
Copy-Item -Force build-main/x265_config.h "$VCPKG_INSTALLED/include/"
# Create pkg-config file for x265 (vcpkg's x265.pc was overwritten)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "vcpkg's x265.pc was overwritten" but this is misleading - x265 was never installed via vcpkg in this workflow (it was explicitly removed from the vcpkg install list), so there's no existing x265.pc file to overwrite. Consider updating the comment to clarify that this creates the pkg-config file since x265 is built from source instead of via vcpkg.

Suggested change
# Create pkg-config file for x265 (vcpkg's x265.pc was overwritten)
# Create pkg-config file for x265 since it is built from source instead of via vcpkg

Copilot uses AI. Check for mistakes.
Copy-Item -Force source/x265.h "$VCPKG_INSTALLED/include/"
Copy-Item -Force build-main/x265_config.h "$VCPKG_INSTALLED/include/"
# Create pkg-config file for x265 (vcpkg's x265.pc was overwritten)
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment states "vcpkg's x265.pc was overwritten" but this is misleading - x265 was never installed via vcpkg in this workflow (it was explicitly removed from the vcpkg install list), so there's no existing x265.pc file to overwrite. Consider updating the comment to clarify that this creates the pkg-config file since x265 is built from source instead of via vcpkg.

Suggested change
# Create pkg-config file for x265 (vcpkg's x265.pc was overwritten)
# Create pkg-config file for x265 since it is built from source instead of via vcpkg

Copilot uses AI. Check for mistakes.
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/arm64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git clone command lacks error handling. If the clone fails (e.g., network issues, repository unavailable), the subsequent commands will fail in confusing ways. Consider adding error handling or using set -e for bash scripts to fail fast on errors.

Suggested change
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
if ($LASTEXITCODE -ne 0) {
Write-Error "git clone of x265 repository failed with exit code $LASTEXITCODE."
exit $LASTEXITCODE
}

Copilot uses AI. Check for mistakes.
Comment on lines +132 to +230
- name: Build x265 with alpha support
shell: pwsh
run: |
# Build x265 from source with ENABLE_ALPHA=ON
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/arm64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
cd x265_git
# Create a local tag for version detection
# git describe --abbrev=0 --tags needs a tag reachable from HEAD
# Shallow clone doesn't have the tag in history, so we create one locally
git tag 4.1
# Build 12-bit lib
# Use ClangCL for ARM64 NEON assembly support
# NOWINBASEINTERLOCK skips winbase.h interlocked wrappers that conflict with ClangCL intrinsics
# /MT uses static CRT to match vcpkg's static triplet (avoids __imp_fwrite link errors)
cmake -B build-12bit -S source -G "Visual Studio 17 2022" -A ARM64 -T ClangCL `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" `
-DCMAKE_C_FLAGS="-DNOWINBASEINTERLOCK" `
-DCMAKE_CXX_FLAGS="-DNOWINBASEINTERLOCK" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
-DHIGH_BIT_DEPTH=ON `
-DEXPORT_C_API=OFF `
-DMAIN12=ON
cmake --build build-12bit --config Release --parallel
# Build 10-bit lib
cmake -B build-10bit -S source -G "Visual Studio 17 2022" -A ARM64 -T ClangCL `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" `
-DCMAKE_C_FLAGS="-DNOWINBASEINTERLOCK" `
-DCMAKE_CXX_FLAGS="-DNOWINBASEINTERLOCK" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
-DHIGH_BIT_DEPTH=ON `
-DEXPORT_C_API=OFF
cmake --build build-10bit --config Release --parallel
# Build 8-bit main lib with linked 10/12-bit
# Use absolute paths for EXTRA_LIB since linker resolves paths from build directory
$x265Dir = (Get-Location).Path -replace '\\','/'
$lib10bit = "$x265Dir/build-10bit/Release/x265-static.lib"
$lib12bit = "$x265Dir/build-12bit/Release/x265-static.lib"
Write-Host "EXTRA_LIB: $lib10bit;$lib12bit"
cmake -B build-main -S source -G "Visual Studio 17 2022" -A ARM64 -T ClangCL `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" `
-DCMAKE_C_FLAGS="-DNOWINBASEINTERLOCK" `
-DCMAKE_CXX_FLAGS="-DNOWINBASEINTERLOCK" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
"-DEXTRA_LIB=$lib10bit;$lib12bit" `
-DLINKED_10BIT=ON `
-DLINKED_12BIT=ON
cmake --build build-main --config Release --parallel
# Combine all libs into single static archive using lib.exe (MSVC)
lib.exe /OUT:x265-combined.lib `
build-main/Release/x265-static.lib `
build-10bit/Release/x265-static.lib `
build-12bit/Release/x265-static.lib
# Install to vcpkg directory so FFmpeg can find it
Copy-Item -Force x265-combined.lib "$VCPKG_INSTALLED/lib/x265-static.lib"
Copy-Item -Force source/x265.h "$VCPKG_INSTALLED/include/"
Copy-Item -Force build-main/x265_config.h "$VCPKG_INSTALLED/include/"
# Create pkg-config file for x265 (vcpkg's x265.pc was overwritten)
# Convert path to forward slashes for pkg-config compatibility
$pkgconfigDir = "$VCPKG_INSTALLED/lib/pkgconfig"
$prefixUnix = $VCPKG_INSTALLED -replace '\\','/'
New-Item -ItemType Directory -Force -Path $pkgconfigDir | Out-Null
$x265pc = @(
"prefix=$prefixUnix"
'exec_prefix=${prefix}'
'libdir=${prefix}/lib'
'includedir=${prefix}/include'
''
'Name: x265'
'Description: H.265/HEVC video encoder with alpha support'
'Version: 4.1'
'Libs: -L${libdir} -lx265-static'
'Libs.private: -lstdc++'
'Cflags: -I${includedir}'
) -join "`n"
# Use ASCII encoding to avoid UTF-8 BOM which breaks pkg-config
[System.IO.File]::WriteAllText("$pkgconfigDir/x265.pc", $x265pc)
Write-Host "x265 with alpha support installed to $VCPKG_INSTALLED"
Write-Host "x265.pc content:"
Get-Content "$pkgconfigDir/x265.pc"
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PowerShell script lacks proper error handling via $ErrorActionPreference. If any command fails (git clone, cmake, lib.exe, Copy-Item), the script continues executing which could lead to incomplete or corrupted builds. Consider adding $ErrorActionPreference = 'Stop' at the beginning of the script block to fail fast on errors.

Copilot uses AI. Check for mistakes.
Comment on lines +560 to +565
run: |
# Build x265 from source with ENABLE_ALPHA=ON
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/x64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The git clone command lacks error handling. If the clone fails (e.g., network issues, repository unavailable), the subsequent commands will fail in confusing ways. Consider adding error handling or using $ErrorActionPreference = 'Stop' at the beginning of the script block to fail fast on errors.

Suggested change
run: |
# Build x265 from source with ENABLE_ALPHA=ON
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/x64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
run: |
$ErrorActionPreference = 'Stop'
# Build x265 from source with ENABLE_ALPHA=ON
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/x64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
if ($LASTEXITCODE -ne 0) {
throw "git clone of x265 repository failed with exit code $LASTEXITCODE."
}

Copilot uses AI. Check for mistakes.
Comment on lines +558 to +648
- name: Build x265 with alpha support
shell: pwsh
run: |
# Build x265 from source with ENABLE_ALPHA=ON
# vcpkg's x265 doesn't have alpha support enabled
$VCPKG_INSTALLED = "$env:VCPKG_ROOT/installed/x64-windows-static"
git clone --depth 1 --branch Release_4.1 https://bitbucket.org/multicoreware/x265_git.git
cd x265_git
# Create a local tag for version detection
# git describe --abbrev=0 --tags needs a tag reachable from HEAD
# Shallow clone doesn't have the tag in history, so we create one locally
git tag 4.1
# Build 12-bit lib
# CMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded uses /MT (static CRT) to match vcpkg's static triplet
cmake -B build-12bit -S source -G "Visual Studio 17 2022" -A x64 `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
-DHIGH_BIT_DEPTH=ON `
-DEXPORT_C_API=OFF `
-DMAIN12=ON
cmake --build build-12bit --config Release --parallel
# Build 10-bit lib
cmake -B build-10bit -S source -G "Visual Studio 17 2022" -A x64 `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
-DHIGH_BIT_DEPTH=ON `
-DEXPORT_C_API=OFF
cmake --build build-10bit --config Release --parallel
# Build 8-bit main lib with linked 10/12-bit
# Use absolute paths for EXTRA_LIB since linker resolves paths from build directory
$x265Dir = (Get-Location).Path -replace '\\','/'
$lib10bit = "$x265Dir/build-10bit/Release/x265-static.lib"
$lib12bit = "$x265Dir/build-12bit/Release/x265-static.lib"
Write-Host "EXTRA_LIB: $lib10bit;$lib12bit"
cmake -B build-main -S source -G "Visual Studio 17 2022" -A x64 `
-DCMAKE_INSTALL_PREFIX="$VCPKG_INSTALLED" `
-DCMAKE_MSVC_RUNTIME_LIBRARY="MultiThreaded" `
-DENABLE_SHARED=OFF `
-DENABLE_CLI=OFF `
-DENABLE_ALPHA=ON `
"-DEXTRA_LIB=$lib10bit;$lib12bit" `
-DLINKED_10BIT=ON `
-DLINKED_12BIT=ON
cmake --build build-main --config Release --parallel
# Combine all libs into single static archive using lib.exe (MSVC)
lib.exe /OUT:x265-combined.lib `
build-main/Release/x265-static.lib `
build-10bit/Release/x265-static.lib `
build-12bit/Release/x265-static.lib
# Install to vcpkg directory so FFmpeg can find it
Copy-Item -Force x265-combined.lib "$VCPKG_INSTALLED/lib/x265-static.lib"
Copy-Item -Force source/x265.h "$VCPKG_INSTALLED/include/"
Copy-Item -Force build-main/x265_config.h "$VCPKG_INSTALLED/include/"
# Create pkg-config file for x265 (vcpkg's x265.pc was overwritten)
# Convert path to forward slashes for pkg-config compatibility
$pkgconfigDir = "$VCPKG_INSTALLED/lib/pkgconfig"
$prefixUnix = $VCPKG_INSTALLED -replace '\\','/'
New-Item -ItemType Directory -Force -Path $pkgconfigDir | Out-Null
$x265pc = @(
"prefix=$prefixUnix"
'exec_prefix=${prefix}'
'libdir=${prefix}/lib'
'includedir=${prefix}/include'
''
'Name: x265'
'Description: H.265/HEVC video encoder with alpha support'
'Version: 4.1'
'Libs: -L${libdir} -lx265-static'
'Libs.private: -lstdc++'
'Cflags: -I${includedir}'
) -join "`n"
# Use ASCII encoding to avoid UTF-8 BOM which breaks pkg-config
[System.IO.File]::WriteAllText("$pkgconfigDir/x265.pc", $x265pc)
Write-Host "x265 with alpha support installed to $VCPKG_INSTALLED"
Write-Host "x265.pc content:"
Get-Content "$pkgconfigDir/x265.pc"
Copy link

Copilot AI Jan 1, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PowerShell script lacks proper error handling via $ErrorActionPreference. If any command fails (git clone, cmake, lib.exe, Copy-Item), the script continues executing which could lead to incomplete or corrupted builds. Consider adding $ErrorActionPreference = 'Stop' at the beginning of the script block to fail fast on errors.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants