Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ jobs:
arch: x86_64
generator: "MSYS Makefiles"
shell: msys2 {0}
msystem: ucrt64
toolchain: ucrt-x86_64
- name: Windows-ARM64
os: windows-11-arm
arch: aarch64
generator: "MSYS Makefiles"
shell: msys2 {0}
msystem: clangarm64
toolchain: clang-aarch64
defaults:
run:
shell: ${{ matrix.shell }}
Expand Down Expand Up @@ -269,21 +278,23 @@ jobs:
if: runner.os == 'Windows'
uses: msys2/setup-msys2@v2
with:
msystem: ucrt64
msystem: ${{ matrix.msystem }}
update: true

- name: Update Windows dependencies
env:
MSYSTEM: ucrt64
TOOLCHAIN: ucrt-x86_64
MSYSTEM: ${{ matrix.msystem }}
TOOLCHAIN: ${{ matrix.toolchain }}
if: runner.os == 'Windows'
shell: msys2 {0}
run: |
# variables
declare -A pinned_deps
pinned_deps["mingw-w64-${TOOLCHAIN}-cmake"]="3.31.6-1"
pinned_deps["mingw-w64-${TOOLCHAIN}-gcc"]="14.2.0-3"
pinned_deps["mingw-w64-${TOOLCHAIN}-gcc-libs"]="14.2.0-3"
if [[ ${MSYSTEM} == "ucrt64" ]]; then
pinned_deps["mingw-w64-${TOOLCHAIN}-gcc"]="14.2.0-3"
pinned_deps["mingw-w64-${TOOLCHAIN}-gcc-libs"]="14.2.0-3"
fi

dependencies=(
"diffutils"
Expand Down Expand Up @@ -331,7 +342,8 @@ jobs:
- name: Debug msys2.CMD
if: runner.os == 'Windows'
run: |
cat /d/a/_temp/setup-msys2/msys2.CMD
echo "MSYS2_ROOT=${{ runner.temp }}/msys64" >> $GITHUB_ENV
cat "${{ runner.temp }}/setup-msys2/msys2.CMD"

- name: Initialize Submodules
# libx265 has issues when using the recursive method of the first checkout action
Expand Down
27 changes: 23 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,11 +51,17 @@ elseif(NOT N MATCHES "^[0-9]+$")
set(N_PROC 1)
endif()

set(MSYS2_ROOT "C:/msys64")
if(WIN32 AND DEFINED ENV{MSYS2_ROOT})
set(MSYS2_ROOT "$ENV{MSYS2_ROOT}")
message(STATUS "Detected MSYS2_ROOT, get msys2 path from environment: ${MSYS2_ROOT}")
endif()

if(NOT DEFINED BASH_EXECUTABLE)
find_program(BASH_EXECUTABLE
NAMES zsh bash
REQUIRED
HINTS D:/a/_temp/msys64/usr/bin C:/msys64/usr/bin /bin /usr/bin /usr/local/bin)
HINTS "${MSYS2_ROOT}/usr/bin" /bin /usr/bin /usr/local/bin)
message(STATUS "Found bash: ${BASH_EXECUTABLE}")
endif()

Expand All @@ -70,12 +76,25 @@ if(WIN32)
set(MAKE_EXECUTABLE "make")
message(STATUS "Detected Windows, falling back to using make: ${MAKE_EXECUTABLE}")

# fatal error when cross compiling
if(CMAKE_CROSSCOMPILING)
message(STATUS "System processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "Host system processor: ${CMAKE_HOST_SYSTEM_PROCESSOR}")
message(FATAL_ERROR "Cross-compiling is not supported on Windows")
endif()

set(MSYSTEM "UCRT64")
find_file(MSYS2_EXECUTABLE NAMES msys2_shell.cmd REQUIRED HINTS D:/a/_temp/msys64 C:/msys64)
set(MSYS2_ARG "-ucrt64")
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64")
set(MSYSTEM "CLANGARM64")
set(MSYS2_ARG "-clangarm64")
endif()

find_file(MSYS2_EXECUTABLE NAMES msys2_shell.cmd REQUIRED HINTS ${MSYS2_ROOT})
message(STATUS "Found MSYS2: ${MSYS2_EXECUTABLE}")

if(NOT DEFINED MSYS2_OPTION OR MSYS2_OPTION STREQUAL "1" OR MSYS2_OPTION STREQUAL "")
set(SHELL_CMD ${MSYS2_EXECUTABLE} -ucrt64 -defterm -here -no-start -shell bash -c)
set(SHELL_CMD ${MSYS2_EXECUTABLE} ${MSYS2_ARG} -defterm -here -no-start -shell bash -c)
elseif(MSYS2_OPTION STREQUAL "2")
# Theoretically, this is equivalent to the above
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/msys2.cmd.in ${CMAKE_CURRENT_BINARY_DIR}/msys2.cmd @ONLY)
Expand Down Expand Up @@ -135,7 +154,7 @@ message(STATUS "Initial PKG_CONFIG_PATH: ${PKG_CONFIG_PATH}")
find_program(PKG_CONFIG_EXECUTABLE
NAMES pkg-config
REQUIRED
HINTS D:/a/_temp/msys64/usr/bin C:/msys64/usr/bin /bin /usr/bin /usr/local/bin)
HINTS "${MSYS2_ROOT}/usr/bin" /bin /usr/bin /usr/local/bin)
UNIX_PATH(PKG_CONFIG_EXECUTABLE ${PKG_CONFIG_EXECUTABLE})
message(STATUS "Found pkg-config: ${PKG_CONFIG_EXECUTABLE}")

Expand Down
28 changes: 27 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,13 @@ brew install \

#### Windows

First, install [MSYS2](https://www.msys2.org/), then open the UCRT64 shell and run the following commands:
ℹ️ Cross-compilation is not supported on Windows. You must build on the target architecture.

First, install [MSYS2](https://www.msys2.org/).

##### x86_64 / amd64

Open the UCRT64 shell and run the following commands:

```bash
pacman -Syu
Expand All @@ -139,6 +145,26 @@ pacman -S \
mingw-w64-ucrt-x86_64-onevpl
```

##### aarch64 / arm64

Open the CLANGARM64 shell and run the following commands:

```bash
pacman -Syu
pacman -S \
diffutils \
git \
make \
pkg-config \
mingw-w64-clang-aarch64-binutils \
mingw-w64-clang-aarch64-cmake \
mingw-w64-clang-aarch64-gcc \
mingw-w64-clang-aarch64-make \
mingw-w64-clang-aarch64-nasm \
mingw-w64-clang-aarch64-ninja \
mingw-w64-clang-aarch64-onevpl
```

### Configure

Use the `Unix Makefiles` generator for Linux and macOS, and the `MSYS Makefiles` generator for Windows.
Expand Down
26 changes: 22 additions & 4 deletions cmake/ffmpeg/ffmpeg.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -52,17 +52,35 @@ list(APPEND FFMPEG_EXTRA_CONFIGURE
if(WIN32)
list(APPEND FFMPEG_EXTRA_CONFIGURE
--enable-amf
--enable-cuda
--enable-d3d11va
--enable-encoder=h264_amf,hevc_amf,av1_amf
--enable-encoder=h264_mf,hevc_mf
--enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc
--enable-encoder=h264_qsv,hevc_qsv,av1_qsv
--enable-ffnvcodec
--enable-libvpl
--enable-nvenc
--enable-mediafoundation
)

# On Windows Arm64
# We must specify the arch parameter until one of the following issues is resolved
#
# https://github.com/msys2/msys2-runtime/issues/171
# https://github.com/FFmpeg/FFmpeg/blob/4e5523c98597a417eb43555933b1075d18ec5f8b/configure#L4161
#
# We must disable CUDA and NVENC until following issues is resolved
#
# https://github.com/FFmpeg/FFmpeg/blob/4e5523c98597a417eb43555933b1075d18ec5f8b/configure#L7443
if(${arch} STREQUAL "aarch64" OR ${arch} STREQUAL "arm64")
list(APPEND FFMPEG_EXTRA_CONFIGURE
--arch=${arch}
)
elseif (${arch} STREQUAL "amd64" OR ${arch} STREQUAL "x86_64")
list(APPEND FFMPEG_EXTRA_CONFIGURE
--enable-cuda
--enable-encoder=h264_nvenc,hevc_nvenc,av1_nvenc
--enable-ffnvcodec
--enable-nvenc
)
endif()
elseif(APPLE)
list(APPEND FFMPEG_EXTRA_CONFIGURE
--enable-encoder=h264_videotoolbox,hevc_videotoolbox
Expand Down
15 changes: 13 additions & 2 deletions cmake/ffmpeg/x264.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ else()
endif()

if(WIN32)
set(X264_HOST ${X264_ARCH}-windows)
set(X264_HOST ${X264_ARCH}-mingw64)
elseif(APPLE)
set(X264_HOST ${X264_ARCH}-macos)
set(X264_HOST ${X264_ARCH}-darwin)
elseif(UNIX)
set(X264_HOST ${X264_ARCH}-linux)
else()
Expand All @@ -37,6 +37,17 @@ if(CMAKE_CROSSCOMPILING)
endif()
endif()

# On Windows Arm64
# We must specify the host parameter until one of the following issues is resolved
#
# https://github.com/msys2/msys2-runtime/issues/171
# https://code.videolan.org/videolan/x264/-/tree/1ecc51ee971e0056a53bd6cf9c6f6af18b167e4b/config.guess#L809
if(${X264_HOST} STREQUAL "aarch64-mingw64")
set(FFMPEG_X264_EXTRA_CONFIGURE
--host=${X264_HOST}
)
endif()

# convert list to string
# configure command will only take the first argument if not converted to string
string(REPLACE ";" " " FFMPEG_X264_EXTRA_CONFIGURE "${FFMPEG_X264_EXTRA_CONFIGURE}")
Expand Down
2 changes: 1 addition & 1 deletion msys2.cmd.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ setlocal
IF NOT DEFINED MSYSTEM set MSYSTEM=@MSYSTEM@
IF NOT DEFINED MSYS2_PATH_TYPE set MSYS2_PATH_TYPE=inherit
set CHERE_INVOKING=1
@MSYS2_EXECUTABLE@ -ucrt64 -defterm -here -no-start -shell bash -c %*
@MSYS2_EXECUTABLE@ @MSYS2_ARG@ -defterm -here -no-start -shell bash -c %*
Loading