From 0984756c19a49570f4be01ab9d2c859af922f5a2 Mon Sep 17 00:00:00 2001 From: Mike Solar Date: Thu, 21 May 2026 17:40:24 +0800 Subject: [PATCH] fix: Compile v8.1.1 instead of latest ffmpeg for Ubuntu, remove override for MainWindow::nativeEvent, and change Windows packages to UCRT. --- .github/workflows/ci.yml | 28 ++-- app/window/mainwindow/mainwindow.h | 2 +- docs/build.md | 88 ++++++++--- docs/zh/build.md | 233 +++++++++++++++++++++++++---- 4 files changed, 289 insertions(+), 62 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5d7d0bfda..5f8bbaeaa 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,7 +39,7 @@ jobs: - name: Build FFmpeg from source (Linux) if: runner.os == 'Linux' run: | - git clone --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src + git clone --branch n8.1.1 --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src cd ffmpeg-src ./configure \ --prefix="$PWD/../ffmpeg-install" \ @@ -88,21 +88,21 @@ jobs: if: runner.os == 'Windows' uses: msys2/setup-msys2@v2 with: - msystem: MINGW64 + msystem: UCRT64 update: true install: >- - mingw-w64-x86_64-cmake - mingw-w64-x86_64-ninja - mingw-w64-x86_64-gcc - mingw-w64-x86_64-qt6-base - mingw-w64-x86_64-qt6-tools - mingw-w64-x86_64-ffmpeg - mingw-w64-x86_64-openimageio - mingw-w64-x86_64-opencolorio - mingw-w64-x86_64-openexr - mingw-w64-x86_64-fmt - mingw-w64-x86_64-expat - mingw-w64-x86_64-portaudio + mingw-w64-ucrt-x86_64-cmake + mingw-w64-ucrt-x86_64-ninja + mingw-w64-ucrt-x86_64-gcc + mingw-w64-ucrt-x86_64-qt6-base + mingw-w64-ucrt-x86_64-qt6-tools + mingw-w64-ucrt-x86_64-ffmpeg + mingw-w64-ucrt-x86_64-openimageio + mingw-w64-ucrt-x86_64-opencolorio + mingw-w64-ucrt-x86_64-openexr + mingw-w64-ucrt-x86_64-fmt + mingw-w64-ucrt-x86_64-expat + mingw-w64-ucrt-x86_64-portaudio # ------------------------------------------------------------------ # Configure diff --git a/app/window/mainwindow/mainwindow.h b/app/window/mainwindow/mainwindow.h index cef97f795..a6ff40e3a 100644 --- a/app/window/mainwindow/mainwindow.h +++ b/app/window/mainwindow/mainwindow.h @@ -110,7 +110,7 @@ protected: #ifdef Q_OS_WINDOWS virtual bool nativeEvent(const QByteArray &eventType, void *message, - long *result) override; + long *result); #endif private: diff --git a/docs/build.md b/docs/build.md index 0b11ed481..fbbdd4449 100644 --- a/docs/build.md +++ b/docs/build.md @@ -7,7 +7,7 @@ This document describes how to build Oak Video Editor from source on Windows, Li - CMake 3.20+ - Ninja (recommended) - Qt 6 (with private headers) -- FFmpeg development libraries +- FFmpeg 8.0+ development libraries (distro packages on Ubuntu/Debian are often too old; see the Linux section below) - OpenImageIO - OpenColorIO (2.x) - OpenEXR @@ -20,31 +20,32 @@ This document describes how to build Oak Video Editor from source on Windows, Li ## Windows (MSYS2) -This guide uses [MSYS2](https://www.msys2.org/) with the MinGW-w64 toolchain. +This guide uses [MSYS2](https://www.msys2.org/) with the UCRT64 toolchain. ### 1. Install MSYS2 -Download and install MSYS2 from [https://www.msys2.org/](https://www.msys2.org/). Then open the **MSYS2 MinGW 64-bit** terminal. +Download and install MSYS2 from [https://www.msys2.org/](https://www.msys2.org/). Then open the **MSYS2 UCRT64** terminal. ### 2. Install Dependencies ```bash pacman -Syu pacman -S --needed \ - mingw-w64-x86_64-cmake \ - mingw-w64-x86_64-ninja \ - mingw-w64-x86_64-qt6-base \ - mingw-w64-x86_64-qt6-tools \ - mingw-w64-x86_64-ffmpeg \ - mingw-w64-x86_64-openimageio \ - mingw-w64-x86_64-opencolorio \ - mingw-w64-x86_64-openexr \ - mingw-w64-x86_64-expat \ - mingw-w64-x86_64-portaudio \ - mingw-w64-x86_64-gcc + mingw-w64-ucrt-x86_64-cmake \ + mingw-w64-ucrt-x86_64-ninja \ + mingw-w64-ucrt-x86_64-qt6-base \ + mingw-w64-ucrt-x86_64-qt6-tools \ + mingw-w64-ucrt-x86_64-ffmpeg \ + mingw-w64-ucrt-x86_64-openimageio \ + mingw-w64-ucrt-x86_64-opencolorio \ + mingw-w64-ucrt-x86_64-openexr \ + mingw-w64-ucrt-x86_64-fmt \ + mingw-w64-ucrt-x86_64-expat \ + mingw-w64-ucrt-x86_64-portaudio \ + mingw-w64-ucrt-x86_64-gcc ``` -> **Note:** Qt 6 private headers may require additional packages depending on the MSYS2 repository state. If CMake reports missing private headers, install `mingw-w64-x86_64-qt6-base-private` if available. +> **Note:** Qt 6 private headers may require additional packages depending on the MSYS2 repository state. If CMake reports missing private headers, install `mingw-w64-ucrt-x86_64-qt6-base-private` if available. ### 3. Clone and Build @@ -74,22 +75,44 @@ ctest --test-dir build --output-on-failure -C Release ### Debian / Ubuntu -Install dependencies: +Install dependencies (FFmpeg is built from source below because distro packages are often too old): ```bash sudo apt-get update sudo apt-get install -y \ - cmake ninja-build pkg-config \ + cmake ninja-build pkg-config nasm \ qt6-base-dev qt6-base-dev-tools qt6-base-private-dev qt6-tools-dev qt6-tools-dev-tools \ - libavcodec-dev libavformat-dev libavfilter-dev libavutil-dev libswscale-dev libswresample-dev \ libopencolorio-dev libopenimageio-dev libopenexr-dev libexpat1-dev \ portaudio19-dev libgl1-mesa-dev libxkbcommon-dev ``` +Build FFmpeg 8.0+ from source: + +```bash +git clone --branch n8.1.1 --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src +cd ffmpeg-src +./configure \ + --prefix="$PWD/../ffmpeg-install" \ + --enable-static \ + --disable-shared \ + --disable-doc \ + --disable-programs \ + --disable-avdevice \ + --disable-network \ + --enable-pic \ + --enable-gpl \ + --enable-version3 +make -j$(nproc) +make install +cd .. +``` + Configure and build: ```bash -cmake -S . -B build -G Ninja -DBUILD_TESTS=ON -DBUILD_QT6=ON +cmake -S . -B build -G Ninja \ + -DBUILD_TESTS=ON -DBUILD_QT6=ON \ + -DFFMPEG_ROOT="$PWD/ffmpeg-install" cmake --build build --config Release ``` @@ -239,7 +262,7 @@ export PATH="/path/to/qt6/bin:$PATH" export CMAKE_PREFIX_PATH="/path/to/qt6" # Windows (MSYS2) -export PATH="/mingw64/bin:$PATH" +export PATH="/ucrt64/bin:$PATH" ``` ### Missing Private Headers @@ -253,3 +276,28 @@ Make sure FFmpeg development libraries are installed and `pkg-config` can locate ```bash pkg-config --exists libavcodec && echo "Found" || echo "Not found" ``` + +### FFmpeg Version Too Old + +If you encounter errors like `AV_PIX_FMT_GRAYF16 was not declared in this scope`, your FFmpeg is too old (Oak requires 8.0+). Build from source: + +```bash +git clone --branch n8.1.1 --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src +cd ffmpeg-src +./configure \ + --prefix="$PWD/../ffmpeg-install" \ + --enable-static \ + --disable-shared \ + --disable-doc \ + --disable-programs \ + --disable-avdevice \ + --disable-network \ + --enable-pic \ + --enable-gpl \ + --enable-version3 +make -j$(nproc) +make install +cd .. +``` + +Then pass `-DFFMPEG_ROOT="$PWD/ffmpeg-install"` to CMake. diff --git a/docs/zh/build.md b/docs/zh/build.md index 0f1e550c5..a2b4e0baf 100644 --- a/docs/zh/build.md +++ b/docs/zh/build.md @@ -1,13 +1,13 @@ # 构建指南 -本文档介绍如何从源码构建 Oak Video Editor。 +本文档介绍如何在 Windows、Linux 和 macOS 上从源码构建 Oak Video Editor。 ## 依赖 - CMake 3.20+ - Ninja(推荐) - Qt 6(含私有头文件) -- FFmpeg 开发库 +- FFmpeg 8.0+ 开发库(Ubuntu/Debian 系统源里的版本通常太旧,见下文 Linux 章节) - OpenImageIO - OpenColorIO(2.x) - OpenEXR @@ -16,20 +16,131 @@ - OpenGL 头文件 - XKB common(Linux) -## Linux(Ubuntu/Debian) +--- -安装依赖: +## Windows(MSYS2) + +本指南使用 [MSYS2](https://www.msys2.org/) 的 UCRT64 工具链。 + +### 1. 安装 MSYS2 + +从 [https://www.msys2.org/](https://www.msys2.org/) 下载并安装 MSYS2,然后打开 **MSYS2 UCRT64** 终端。 + +### 2. 安装依赖 + +```bash +pacman -Syu +pacman -S --needed \ + mingw-w64-ucrt-x86_64-cmake \ + mingw-w64-ucrt-x86_64-ninja \ + mingw-w64-ucrt-x86_64-qt6-base \ + mingw-w64-ucrt-x86_64-qt6-tools \ + mingw-w64-ucrt-x86_64-ffmpeg \ + mingw-w64-ucrt-x86_64-openimageio \ + mingw-w64-ucrt-x86_64-opencolorio \ + mingw-w64-ucrt-x86_64-openexr \ + mingw-w64-ucrt-x86_64-fmt \ + mingw-w64-ucrt-x86_64-expat \ + mingw-w64-ucrt-x86_64-portaudio \ + mingw-w64-ucrt-x86_64-gcc +``` + +> **注意:** Qt 6 私有头文件可能需要额外安装。如果 CMake 报告找不到私有头文件,请尝试安装 `mingw-w64-ucrt-x86_64-qt6-base-private`(如果仓库中有)。 + +### 3. 克隆并构建 + +```bash +# 克隆仓库 +git clone --recursive https://github.com/OakVideoEditorCommunity/oak.git +cd oak + +# 配置 +cmake -S . -B build -G Ninja \ + -DCMAKE_BUILD_TYPE=Release \ + -DBUILD_QT6=ON + +# 构建 +cmake --build build --config Release +``` + +### 4. 运行测试(可选) + +```bash +ctest --test-dir build --output-on-failure -C Release +``` + +--- + +## Linux + +### Debian / Ubuntu + +安装依赖(FFmpeg 需要自行从源码编译,因为系统源里的版本通常太旧): ```bash sudo apt-get update sudo apt-get install -y \ - ninja-build pkg-config \ + cmake ninja-build pkg-config nasm \ qt6-base-dev qt6-base-dev-tools qt6-base-private-dev qt6-tools-dev qt6-tools-dev-tools \ - libavcodec-dev libavformat-dev libavfilter-dev libavutil-dev libswscale-dev libswresample-dev \ libopencolorio-dev libopenimageio-dev libopenexr-dev libexpat1-dev \ portaudio19-dev libgl1-mesa-dev libxkbcommon-dev ``` +从源码编译 FFmpeg 8.0+: + +```bash +git clone --branch n8.1.1 --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src +cd ffmpeg-src +./configure \ + --prefix="$PWD/../ffmpeg-install" \ + --enable-static \ + --disable-shared \ + --disable-doc \ + --disable-programs \ + --disable-avdevice \ + --disable-network \ + --enable-pic \ + --enable-gpl \ + --enable-version3 +make -j$(nproc) +make install +cd .. +``` + +配置并构建: + +```bash +cmake -S . -B build -G Ninja \ + -DBUILD_TESTS=ON -DBUILD_QT6=ON \ + -DFFMPEG_ROOT="$PWD/ffmpeg-install" +cmake --build build --config Release +``` + +运行测试: + +```bash +ctest --test-dir build --output-on-failure -C Release +``` + +### Fedora + +安装依赖: + +```bash +sudo dnf install -y \ + cmake ninja-build pkgconf-pkg-config \ + qt6-qtbase-devel qt6-qtbase-private-devel qt6-qttools-devel \ + ffmpeg-devel \ + OpenImageIO-devel \ + OpenColorIO-devel \ + openexr-devel \ + expat-devel \ + portaudio-devel \ + mesa-libGL-devel \ + libxkbcommon-devel \ + gcc-c++ +``` + 配置并构建: ```bash @@ -43,6 +154,43 @@ cmake --build build --config Release ctest --test-dir build --output-on-failure -C Release ``` +### Arch Linux + +安装依赖: + +```bash +sudo pacman -Syu +sudo pacman -S --needed \ + cmake ninja pkgconf \ + qt6-base qt6-tools \ + ffmpeg \ + openimageio \ + opencolorio \ + openexr \ + expat \ + portaudio \ + mesa \ + libxkbcommon \ + gcc +``` + +> **注意:** Arch Linux 的 `qt6-base` 包已经包含私有头文件。 + +配置并构建: + +```bash +cmake -S . -B build -G Ninja -DBUILD_TESTS=ON -DBUILD_QT6=ON +cmake --build build --config Release +``` + +运行测试: + +```bash +ctest --test-dir build --output-on-failure -C Release +``` + +--- + ## macOS(非官方支持) 说明:macOS **非官方支持**,目前只做 CI 自动化测试,不做人工测试。 @@ -51,7 +199,7 @@ ctest --test-dir build --output-on-failure -C Release ```bash brew update -brew install ninja pkg-config qt@6 ffmpeg openimageio opencolorio openexr portaudio expat +brew install cmake ninja pkg-config qt@6 ffmpeg openimageio opencolorio openexr portaudio expat ``` 构建 OpenTimelineIO(可选,如需 OTIO 支持): @@ -87,30 +235,61 @@ cmake --build build --config Release ctest --test-dir build --output-on-failure -C Release ``` -## Windows +--- -Qt 6 请使用系统安装器或 CI action。其余依赖建议用 vcpkg。 +## 构建选项 -```powershell -choco install -y ninja -$env:VCPKG_ROOT = "C:\vcpkg" -& "$env:VCPKG_ROOT\vcpkg.exe" install ffmpeg openimageio opencolorio openexr expat portaudio --triplet x64-windows +| 选项 | 默认值 | 说明 | +|------|--------|------| +| `BUILD_TESTS` | `OFF` | 构建单元测试 | +| `BUILD_DOXYGEN` | `OFF` | 构建 Doxygen 文档 | +| `USE_WERROR` | `OFF` | 将警告视为错误 | +| `BUILD_QT6` | `ON` | 使用 Qt 6 而非 Qt 5 | +| `OTIO_LOCATION` | - | OpenTimelineIO 安装路径(可选) | +| `OCIO_LOCATION` | - | OpenColorIO 安装路径 | + +--- + +## 故障排除 + +### 找不到 Qt 6 + +确保 Qt 6 在 PATH 和 CMake prefix path 中: + +```bash +# Linux / macOS +export PATH="/path/to/qt6/bin:$PATH" +export CMAKE_PREFIX_PATH="/path/to/qt6" + +# Windows(MSYS2) +export PATH="/ucrt64/bin:$PATH" ``` -配置并构建: +### 缺少私有头文件 -```powershell -cmake -S . -B build -G Ninja ` - -DBUILD_TESTS=ON ` - -DBUILD_QT6=ON ` - -DCMAKE_BUILD_TYPE=Release ` - -DCMAKE_TOOLCHAIN_FILE="$env:VCPKG_ROOT\scripts\buildsystems\vcpkg.cmake" ` - -DCMAKE_PREFIX_PATH="$env:Qt6_DIR" -cmake --build build --config Release +如果看到缺少 Qt 私有头文件的错误,请安装对应发行版的私有开发包(例如 Debian/Ubuntu 上的 `qt6-base-private-dev`,Fedora 上的 `qt6-qtbase-private-devel`)。 + +### FFmpeg 版本太旧 + +如果遇到 `AV_PIX_FMT_GRAYF16 was not declared in this scope` 之类的错误,说明你的 FFmpeg 版本太旧(Oak 需要 8.0+)。请从源码编译: + +```bash +git clone --branch n8.1.1 --depth 1 https://git.ffmpeg.org/ffmpeg.git ffmpeg-src +cd ffmpeg-src +./configure \ + --prefix="$PWD/../ffmpeg-install" \ + --enable-static \ + --disable-shared \ + --disable-doc \ + --disable-programs \ + --disable-avdevice \ + --disable-network \ + --enable-pic \ + --enable-gpl \ + --enable-version3 +make -j$(nproc) +make install +cd .. ``` -运行测试: - -```powershell -ctest --test-dir build --output-on-failure -C Release -``` +然后在 CMake 中加上 `-DFFMPEG_ROOT="$PWD/ffmpeg-install"`。