From 122b14dfab61a22ad9703d6ba832282634b35dc5 Mon Sep 17 00:00:00 2001 From: Trevor Gamblin Date: Thu, 5 Feb 2026 15:19:08 -0500 Subject: [PATCH 1/2] build-ffmpeg: enable riscv64 Disable cuda and amf for this mode (like arm64) since they don't seem to support riscv64 yet. Signed-off-by: Trevor Gamblin --- .github/workflows/build-ffmpeg.yml | 2 +- scripts/build-ffmpeg.py | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-ffmpeg.yml b/.github/workflows/build-ffmpeg.yml index bb17aee2..9d798b3f 100644 --- a/.github/workflows/build-ffmpeg.yml +++ b/.github/workflows/build-ffmpeg.yml @@ -104,7 +104,7 @@ jobs: matrix: build: [ "manylinux_", "musllinux_" ] # arch: [ "loongarch64", "ppc64le", "riscv64", "s390x" ] - arch: [ "ppc64le" ] + arch: [ "ppc64le", "riscv64" ] steps: - uses: actions/checkout@v6 - uses: actions/setup-python@v6 diff --git a/scripts/build-ffmpeg.py b/scripts/build-ffmpeg.py index 32a51139..447af2ac 100644 --- a/scripts/build-ffmpeg.py +++ b/scripts/build-ffmpeg.py @@ -280,11 +280,12 @@ def main(): machine = platform.machine().lower() is_arm = machine in {"arm64", "aarch64"} + is_riscv = machine in {"riscv64"} use_alsa = plat == "Linux" # CUDA, AMF, and Intel VPL are not available on ARM64 Windows - use_cuda = plat in {"Linux", "Windows"} and not is_arm - use_amf = plat in {"Linux", "Windows"} and not is_arm + use_cuda = plat in {"Linux", "Windows"} and not is_arm and not is_riscv + use_amf = plat in {"Linux", "Windows"} and not is_arm and not is_riscv # Use Intel VPL (Video Processing Library) if supported to enable Intel QSV (Quick Sync Video) # hardware encoders/decoders on modern integrated and discrete Intel GPUs. From ba38cace8cf65a6f05c516e286cd36c642b463ce Mon Sep 17 00:00:00 2001 From: Trevor Gamblin Date: Mon, 16 Mar 2026 14:19:29 -0400 Subject: [PATCH 2/2] ffmpeg.patch: include asm/unistd.h for libavutil The real issue with musl builds seems to be: | src/libavutil/riscv/cpu.c:43:24: error: use of undeclared identifier '__NR_riscv_hwprobe'; did you mean '__riscv_hwprobe'? | 43 | return syscall(__NR_riscv_hwprobe, pairs, pair_count, cpu_count, cpus, | | ^~~~~~~~~~~~~~~~~~ | | __riscv_hwprobe | src/libavutil/riscv/cpu.c:39:12: note: '__riscv_hwprobe' declared here but in the musllinux image, that's defined in unistd_32.h and/or unistd_64.h: |tgamblin@megalith ~/workspace/git/ffmpeg (master)$ docker run --rm --platform linux/riscv64 quay.io/pypa/musllinux_1_2_riscv64:2026.03.01-1 sh -c "grep -r 'riscv_hwprobe' /usr/include/" |/usr/include/asm/hwprobe.h:struct riscv_hwprobe { |/usr/include/asm/unistd_32.h:#define __NR_riscv_hwprobe 258 |/usr/include/asm/unistd_64.h:#define __NR_riscv_hwprobe 258 Tweak the existing ffmpeg.patch file to also include asm/unistd.h in libavutil/riscv/cpu.c. Signed-off-by: Trevor Gamblin --- patches/ffmpeg.patch | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/patches/ffmpeg.patch b/patches/ffmpeg.patch index 1f3bb770..631cef2f 100644 --- a/patches/ffmpeg.patch +++ b/patches/ffmpeg.patch @@ -1,8 +1,8 @@ diff --git a/configure b/configure -index 732de59292..136347a0d2 100755 +index 8f9fb04115..a70c24378d 100755 --- a/configure +++ b/configure -@@ -1886,8 +1886,6 @@ EXTERNAL_LIBRARY_GPL_LIST=" +@@ -1996,8 +1996,6 @@ EXTERNAL_LIBRARY_GPL_LIST=" libdvdread librubberband libvidstab @@ -11,12 +11,24 @@ index 732de59292..136347a0d2 100755 libxavs libxavs2 libxvid -@@ -1900,6 +1898,8 @@ EXTERNAL_LIBRARY_NONFREE_LIST=" +@@ -2010,6 +2008,8 @@ EXTERNAL_LIBRARY_NONFREE_LIST=" " - + EXTERNAL_LIBRARY_VERSION3_LIST=" + libx264 + libx265 gmp libaribb24 liblensfun +diff --git a/libavutil/riscv/cpu.c b/libavutil/riscv/cpu.c +index 8cc91625c7..481d63a39f 100644 +--- a/libavutil/riscv/cpu.c ++++ b/libavutil/riscv/cpu.c +@@ -36,6 +36,7 @@ + #include + #elif HAVE_ASM_HWPROBE_H + #include ++#include + #include + #include +