# media-autobuild_suite **Repository Path**: LeoSasion/media-autobuild_suite ## Basic Information - **Project Name**: media-autobuild_suite - **Description**: 此Windows Batchscript可自动部署编译ffmpeg的环境, 由Nepeta进行本土化(翻译、镜像源) - **Primary Language**: Unknown - **License**: GPL-3.0 - **Default Branch**: master - **Homepage**: https://github.com/m-ab-s/media-autobuild_suite - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 2 - **Created**: 2023-10-07 - **Last Updated**: 2025-11-24 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # media-autobuild_suite 在打开问题之前,请直接从执行套件中检查问题是否存在。这不是Doom9、reddit、stackoverflow或任何其他关于正在编译的东西的一般问题的论坛。这个脚本构建了它们,仅此而已。 此源代码也镜像在[GitLab]中(https://gitlab.com/RiCON/media-autobuild_suite)。 套件中的大多数git源代码都使用GitHub,所以如果它坏了,那么当时运行套件可能没有用。 ##下载 **[单击此处下载最新版本](https://github.com/m-ab-s/media-autobuild_suite/archive/master.zip)** 有关编译器环境的信息,请参阅wiki,在那里您还有一个如何编译自己的工具的示例。 ##包含的工具和库 ###[有关FFmpeg外部库的信息](https://github.com/m-ab-s/media-autobuild_suite/wiki/ffmpeg_options.txt) -FFmpeg(共享或静态)与这些库(均为可选,但除非另有说明,否则默认编译): - Light build(轻量级): - amd amf encoders (内置) - cuda (内置) - cuda-llvm (内置) - cuvid (内置) - ffnvcodec (git) - libaom (git) - libdav1d (git) - libfdk-aac (git) - needs non-free license if not LGPL - libmp3lame (mingw-w64) - libopus (mingw-w64) - libvorbis (mingw-w64) - libvpx (git) - libx264 (git) - libx265 (git) - nvdec (内置) - nvenc (内置) - schannel with gmp (mingw-w64) - 如果未启用openssl、libtls、mbedtls或gnutls,则默认启用 - gmp可以通过gcrypt(mingw-w64)与--enable gcrypt进行切换 - sdl2 (2.0.10) (ffplay需要) - 默认情况下已启用,如果不需要,请使用--disable-sdl2 - Zeranoe-emulating build (相对于Light额外的库) - avisynthplus (需要安装avisynth dll) - fontconfig (最新版本) - 一次只能启用其中一个TLS库(包括schannel): - openssl (mingw-w64) - 如果所有三个选项都可用,那么优先考虑gnutls和libtls - 需要非GPL许可证 - libtls (from libressl) (最新版本) - 需要非GPL许可证 - mbedtls (mingw-w64) - 如果选择GPLv3许可证,则首选gnutls - gnutls (最新版本) - libass (git) - 默认情况下使用DirectWrite后端 - if --enable-fontconfig, fontconfig backend included - with harfbuzz (最新版本) - libbluray (git) - BD-J支持需要安装Java JDK(Java开发工具包) - 编译后的BD-J支持可能仅需要JRE(Java运行时环境)(未经测试) - libfreetype (最新版本) - libgsm (mingw-w64) - libmfx (git) - libmodplug (mingw-w64) - libopencore-amr(nb/wb) (mingw-w64) - libopenjpeg2 (mingw-w64) - libopenmpt (git tag) - librav1e (git) - libsnappy (mingw-w64) - libsoxr (git) - libspeex (mingw-w64) - libsrt (git) - libsvtav1 (git) - libtheora (mingw-w64) - libtwolame (mingw-w64) - libvidstab (git 快照) - libvmaf (git) - libvo-amrwbenc (0.1.3) - libwebp (git) - libxml2 (mingw-w64) - libxvid (1.3.7) - libzimg (git) - Full build (相对于Zeranoe的额外库) - chromaprint (mingw-w64) - cuda filters (needs CUDA SDK installed) - needs non-free license - decklink (12.3) - needs non-free license - frei0r (git) - ladspa (mingw-w64) - libaribb24 (git) - libbs2b (3.1.0) - libcaca (mingw-w64) - libcdio (mingw-w64) - libcodec2 (git) - libdavs2 (git) - libflite (git) - libfribidi (最新版本) - libglslang (git) - libgme (git 快照) - libilbc (git 快照) - libjxl (git) - libkvazaar (git) - libmysofa (git) - needed for sofalizer filter - libnpp (needs CUDA SDK installed) - needs non-free license - libopenh264 (official binaries) - librist (git) - librtmp (git) - librubberband (git 快照) - libssh (broken) - libsvthevc (git) (使用非上游补丁) - libsvtvp9 (git) (使用非上游补丁) - libtesseract (git) - libuavs3d (git) - libxavs (git) - libxavs2 (git) - libzmq (mingw-w64) - libzvbi (0.2.35) - openal (git) - opencl (from system) - opengl (from system) - vapoursynth (R57) - vulkan (git) - other tools - aom (git) - bmx (git) - curl (最新版本) with WinSSL/LibreSSL/OpenSSL/mbedTLS/GnuTLS backend - cyanrip (git) - dav1d (git) - dssim (git) - exhale (git) - faac (1.30) - fdk-aac (git) - ffmbc (git) (unsupported) - flac (git) - haisrt tools (git) - jo (git) - jpeg-xl tools (git) - jq (git) - kvazaar (git) - lame (3.100) - libaacs (git) (shared) - libavif (git) with following encoders/decoders: - rav1e (enc only) - aom (enc/dec) - dav1d (dec only) - libbdplus (git) (shared) - mediainfo cli (git) - mp4box (git) - mplayer (svn) (unsupported) - mpv (git) including in addition to ffmpeg libs: - Base build (ffmpegChoice=2 or 3) - ANGLE Headers (git) - requires ANGLE shared libraries from somewhere else (i.e. Chrome, Firefox) for gpu-context=angle support - lcms2 (mingw-w64) - libass (git) - libbluray (git) - BD-J support requires installation of Java JDK - BD-J support after compilation probably only requires JRE (untested) - luajit (mingw-w64) - mujs (git) - rubberband (git 快照) - uchardet (mingw-w64) - vulkan, shaderc, spirv-cross, libplacebo (git) - vapoursynth (R52) - Full build (ffmpegChoice=4) - dvdnav (git) - libarchive (mingw-w64) - shared libmpv - openal (git) - opus-tools (git) - rav1e (git) - ripgrep (git) - rtmpdump (git) - sox (14.4.2) - speex (git) - svt-hevc (git) - svt-av1 (git) - tesseract (git) - uvg266 (git) - vvenc & vvdec (git) - vorbis-tools (git 快照) - vpx (VP8 and VP9 8, 10 and 12 bit) (git) - vvc tools (git) - webp tools (git) - x264 (8 and 10 bit, with l-smash [mp4 output], lavf and ffms2) (git) - x265 (8, 10 and 12 bit) (git) - xvc (git) (unsupported) - xvid (1.3.7) -------- ## 要求 -------- - Windows 64位(在Win10 64位上进行了测试) - 不再支持32位主机 - NTFS驱动器 - 用于完整的32位和64位构建的13GB+磁盘空间,仅64位需要8GB+ - 4GB+ RAM - 至少需要Powershell 4,目前不支持Powershell core - 下载 Powershell 5.1 [here](https://www.microsoft.com/en-us/download/details.aspx?id=54616) -------- ## 信息 -------- 这个工具的灵感来自Roger Pack (rdp)非常出色的Linux交叉编译工具: https://github.com/rdp/ffmpeg-windows-build-helpers 它基于msys2,并在Windows 7、8.1和10下进行了测试。 http://sourceforge.net/projects/msys2/ 我使用了来自nu774的一些jscript部分: https://github.com/nu774/fdkaac_autobuild 感谢他们所有人! 这个Windows批处理脚本为Windows下的ffmpeg和其他媒体工具建立了一个Mingw-w64/GCC编译器环境。构建环境后,它将检索并编译所有工具。所有工具都进行了静态编译,不需要外部的.dll文件(有一些可选的例外) 如何使用它: - 下载文件,并将其解压到目标文件夹或git clone项目。编译器和工具将被安装在那里。请确保您使用一个没有空格字符的文件夹。一个好地方可能是:c:\mabs - 双击media-autobuild_suite.bat文件 - 选择您想要为Windows 32位、64位还是两者都编译 - 选择是否要编译非免费工具,如"fdk aac" - 选择您想要使用的CPU(核心)数量 - 稍等片刻,希望过一会儿您会在local32\bin-(audio|global|video)或local64\bin-(audio|global|video)下找到所有的"*.exe"工具 脚本会写入一个ini文件,所以您只需要第一次选择想要构建的内容。 脚本不会构建任何注册表键或系统变量,当您不再需要它时,您可以删除文件夹,您的系统将保持干净。 从头开始构建所有内容大约需要~3小时,具体取决于启用了什么。 查看 [forcing-recompilations](./doc/forcing-recompilations.md) 了解如何强制重新构建所有库/二进制文件。 为了节省一些空间,您可以在编译后删除/build中的所有源文件夹(除了末尾带有"-git"或"-svn"的文件夹)。.bat脚本中有一个选项可以自动删除这些文件夹。 Have fun! ## 故障排除 -------- 如果在编译过程中出现某些错误,请按照以下步骤操作: 1. 确保您使用的是此套件的最新版本,通过下载最新版本并用新文件替换所有文件; 2. 如果您知道哪部分出现故障,请在/build中删除该项目的文件夹并再次运行脚本(例如:如果x264失败,尝试删除/build中的x264-git文件夹); 3. 如果仍然不起作用,创建一个问题并粘贴脚本给出的logs.zip的URL,或者自己将文件附加到问题页面。 4. 如果该套件的贡献者无法重现问题,那么问题可能出在您那边。删除/msys64、/local32和/local64(如果它们存在的话)./build通常是安全的,可以保留,并且可以节省时间; 如果问题是可重现的,那么问题可能出在包本身,或者贡献者会找到可能使其工作的方法。 如果您使用--enable-libnpp和/或--enable-cuda-nvcc编译,请查看 [Notes about CUDA SDK](#notes-about-cuda-sdk) ## 各个文件的功能 -------- `media-autobuild_suite.bat` - 该文件设置msys2系统和编译器环境。在正常使用中,您只需启动此文件。每次启动这个批处理文件时,它都会运行整个过程,但在第一次之后,它只检查一些变量并对MinGW环境进行更新。之后,它只编译从git获取更新的工具。 `/build/media-autobuild_suite.ini` - 首次启动后会生成此文件,并保存您选择的设置。在下次运行之前,您可以编辑它。 `/build/media-suite_compile.sh` - 这是编译脚本,它构建了我们想要的所有库和工具,例如 ffmpeg; mplayer; 等。您也可以查看它,并了解如何编译自己的工具。通常,您可以复制代码并将其粘贴到mintty shell中(除了make -j $cpuCount,在这里您需要输入您的cpu数量)。您不需要启动此脚本,它是由批处理脚本调用的。 `/build/media-suite_update.sh` - 每次运行批处理文件时,都会运行此脚本。它会检查来自msys2的pacman等的更新。 `/build/media-suite_helper.sh` - 该脚本包含由编译和更新使用的辅助函数,如果用户需要,也可以由用户source。 `/build/ffmpeg_options.txt` & `/build/mpv_options.txt` -如果您选择选择自己的FFmpeg/mpv可选库,则此文件将包含在编译之前发送到FFmpeg/mpv的配置脚本的选项。根据需要编辑此文件,以获得一个更小的FFmpeg/mpv,没有您不需要的功能,或者带有默认情况下不编译的附加功能(如果支持)。 ## 可选的用户文件 -------- `/local32|64/etc/custom_profile` & `$HOME/custom_build_options` - 在此处放置您特定环境所需的任何通用/平台调整。请参见/local32|64/etc/profile2.local以获取示例用法。 ## 自定义补丁 -------- 使用自定义补丁并不是官方支持的,如果您使用自定义补丁,请不要期望从这个套件得到太多支持。请向补丁的作者或论坛求助。 - 假设您,作为读者,对bash具有足够的知识,以便理解一些基本术语。如果不是,请自行学习。 - 强烈建议查看 [compile script](build/media-suite_compile.sh) 以找到您想要修改的确切包,并与 [helper script](build/media-suite_compile.sh) 交叉引用功能,以查看实际执行了哪些操作。 - 尽管建议使用helper脚本中提供的函数,但没有什么能阻止您使用实际的命令。 -------- - 要使用自定义补丁,在build文件夹中,创建一个文件名为<仓库的名字>_extra.sh的脚本。 - 对于ffmpeg,文件夹名称是ffmpeg-git,但仓库的名称是ffmpeg:`ffmpeg_extra.sh` - 对于game-music-emu,文件夹名称是game-music-emu-0.6.2,但仓库的名称是game-music-emu:`game-music-emu_extra.sh` - 请注意大小写敏感,所以对于文件夹名SVT-VP9-git(仓库名SVT-VP9),脚本的文件名将是: `SVT-VP9_extra.sh` - 除非另有说明,命令将在克隆/解压的文件夹中运行。(flac_extra.sh将在flac-git内运行命令) 要引用克隆的文件夹本身 (`flac-git` `ffmpeg-git`) ,您可以使用变量 `${REPO_DIR}`. 要引用生成的构建文件夹,您需要使用 `${REPO_DIR}/build-${bits}` 来引用64位构建的build-64bit文件夹或32位构建的build-32bit文件夹。 - 对于某些包,构建文件夹可能略有不同。 shared ffmpeg 的 (`build-shared-${bits}` 或 light build 的 `build-light-${bits}` 等。 尝试至少编译一次以查看生成了哪些文件夹,或浏览 [compile script](build/media-suite_compile.sh)) 如果您同时为32位和64位构建,则可以使用 `if [ "$bits"="64bits" ]; then ; fi` 来设置某些命令,以便只在构建64位时运行它们。\ 请小心处理某些包,因为它们具有独特的构建过程(例如x265、x264和其他一些),因此确保检查编译脚本 Example Script: `/build/aom_extra.sh` for `aom-git` ``` bash #!/bin/bash # Don't automatically run cmake || configure touch do_not_reconfigure # Commands to run before running cmake _pre_cmake(){ # Installs libwebp do_pacman_install libwebp # Downloads the patch and then applies the patch do_patch "https://gist.githubusercontent.com/1480c1/9fa9292afedadcea2b3a3e067e96dca2/raw/50a3ed39543d3cf21160f9ad38df45d9843d8dc5/0001-Example-patch-for-learning-purpose.patch" # Change directory to the build folder cd_safe "build-${bits}" # Run cmake with custom options. This will override the previous cmake commands. # $LOCALDESTDIR refers to local64 or local32 cmake .. -G"Ninja" -DCMAKE_INSTALL_PREFIX="$LOCALDESTDIR" \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_C_COMPILER=clang \ -DBUILD_SHARED_LIBS=off -DENABLE_TOOLS=off } _post_cmake(){ # post cmake and post configure will be unavailable due to "touch do_not_reconfigure" # as the do_not_reconfigure flag will skip the post commands. } # Commands to run before building using ninja _pre_ninja(){ # Change directory to the build folder (Absolute path or relative to aom-git) cd_safe "build-${bits}" # applies a local patch (Absolute or relative to aom-git) do_patch "My-Custom-Patches/test-diff-files.diff" # run a custom ninja command. ninja aom_version_check # Not necessary, but just for readability sake cd_safe .. } ``` Example Script: `/build/ffmpeg_extra.sh` for `ffmpeg-git` ``` bash #!/bin/bash # Force to the suite to think the package has updates to recompile. # Alternatively, you can use "touch recompile" for a similar effect. touch custom_updated _pre_configure(){ # # Apply a patch from ffmpeg's patchwork site. do_patch "https://patchwork.ffmpeg.org/patch/12563/mbox/" am # # Apply a local patch inside the directory where is "ffmpeg_extra.sh" patch -p1 -i "$LOCALBUILDDIR/ffmpeg-0001-my_patch.patch" # # Add extra configure options to ffmpeg (ffmpeg specific) # If you want to add something to ffmpeg not within the suite already # you will need to install it yourself, either through pacman # or compiling from source. FFMPEG_OPTS+=(--enable-libsvthevc) # } _post_make(){ # Don't run configure again. touch "$(get_first_subdir -f)/do_not_reconfigure" # Don't clean the build folder on each successive run. # This is for if you want to keep the current build folder as is and just recompile only. touch "$(get_first_subdir -f)/do_not_clean" } ``` 要获取可能的指令列表,请看 `unset_extra_script` 在 [media-suite_helper.sh](build/media-suite_helper.sh)中。 请注意,它们可能在未来发生变化。 ## 关于CUDA SDK的注意事项 -------- ### 这适用于cuda-nvcc和libnpp,而不是NVENC,默认情况下它与ffmpeg一起构建 要使 `--enable-cuda-nvcc` 和 `--enable-libnpp` 工作,您需要安装NVIDIA的 [CUDA SDK](https://developer.nvidia.com/cuda-toolkit) 并且 `CUDA_PATH` 变量需要在整个系统上设置(通常在CUDA SDK安装时默认设置),并安装VS2017或更高版本,它应该带有 `vswhere.exe`.\ 如果由于某种原因 `CUDA_PATH` 没有设置和/或 `vswhere.exe` 没有安装,您需要使用上述用户文件导出 `CUDA_PATH` 变量路径,并手动导出包含MSVC的 `cl.exe` 的绝对路径 `cygpath` 转换正确 `PATH`. ### 如果您使用默认位置等安装了SDK,并且启用了8.3短路径,或者您安装到一个没有任何空格的目录,您不需要执行以下操作 如果您没有理解上面的句子,希望编译将在第一次成功,否则尝试将SDK和MSVC重新安装到没有任何空格的路径。 只有当在mintty终端中运行以下命令产生一个带有空格的路径,或者如果您禁用了8.3短路径时,您才需要担心。 ```bash cygpath -sm "$CUDA_PATH" ``` 如果运行上述命令产生一个带有空格的路径,您将需要禁用cuda/npp相关内容,或者将您的cuda sdk重新安装到一个没有空格的路径。 ### 在安装CUDA SDK时不应手动禁用任何东西,因为手动禁用随机的组件可能会导致编译失败 举个例子,如果您需要手动设置 `CUDA_PATH` 并在 `PATH` 中包含MSVC的 `cl.exe` 和 `nvcc.exe`二进制文件,那么在 `/local64/etc/custom_profile` 目录下创建一个文本文件,并添加以下这段Bash脚本: ```bash # adapt these to your environment _cuda_basepath="C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA" _cuda_version=10.0 _msvc_basepath="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC" _msvc_version=14.15.26726 _msvc_hostarch=x64 _msvc_targetarch=x64 # you shouldn't need to change these unless your environment is weird or you know what you're doing export CUDA_PATH=$(cygpath -sm "${_cuda_basepath}")/${_cuda_version} export PATH=$PATH:$(dirname "$(cygpath -u "\\${_msvc_basepath}\\${_msvc_version}\bin\Host\\${_msvc_hostarch}\\${_msvc_targetarch}\cl.exe")") export PATH=$PATH:$CUDA_PATH/bin ```