From 01b3f66a550e41f59bdfdb17d592def0e34d2861 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Mon, 13 Jul 2026 13:45:06 +0200 Subject: [PATCH 1/3] Add ffmpeg cli --- recipes/recipes_emscripten/ffmpeg/build.sh | 30 ++++++++++++++----- .../recipes_emscripten/ffmpeg/build_tests.sh | 4 +++ recipes/recipes_emscripten/ffmpeg/recipe.yaml | 12 +++++++- 3 files changed, 38 insertions(+), 8 deletions(-) diff --git a/recipes/recipes_emscripten/ffmpeg/build.sh b/recipes/recipes_emscripten/ffmpeg/build.sh index 317a44dfd5..b348970575 100644 --- a/recipes/recipes_emscripten/ffmpeg/build.sh +++ b/recipes/recipes_emscripten/ffmpeg/build.sh @@ -12,19 +12,20 @@ export PYTHON="${BUILD_PREFIX}/bin/python3" # Makefile variable of the same name. unset SUBDIR -export CFLAGS="-I${PREFIX}/include ${CFLAGS:-}" -export LDFLAGS="-L${PREFIX}/lib ${LDFLAGS:-}" +export CFLAGS="-I${PREFIX}/include -pthread ${CFLAGS:-}" +export LDFLAGS="-L${PREFIX}/lib -pthread ${LDFLAGS:-}" # llvm-nm avoids the broken packaged emnm Python launcher. ./configure \ --prefix="${PREFIX}" \ - --target-os=none --arch=x86_32 --enable-cross-compile \ - --disable-asm --disable-stripping --disable-programs \ + --target-os=none --arch=wasm --enable-cross-compile \ + --disable-stripping \ --disable-doc --disable-debug --disable-runtime-cpudetect \ - --disable-autodetect --disable-pthreads --disable-w32threads \ + --disable-autodetect --enable-pthreads --disable-w32threads \ --disable-os2threads --disable-ffplay --disable-network \ --enable-static --disable-shared \ --enable-gpl --enable-version3 \ + --enable-ffmpeg --enable-ffprobe \ --nm=llvm-nm --ar=emar --ranlib=emranlib \ --cc=emcc --cxx=em++ --objcc=emcc --dep-cc=emcc \ --enable-avcodec --enable-avformat --enable-avutil \ @@ -32,8 +33,23 @@ export LDFLAGS="-L${PREFIX}/lib ${LDFLAGS:-}" --enable-avfilter --enable-avdevice \ --enable-protocol=file -make -j"${CPU_COUNT:-4}" -make install +make EXESUF=.js -j"${CPU_COUNT:-4}" +make EXESUF=.js install + +# FFmpeg's Emscripten link creates *_g.wasm and copies only the JavaScript +# launcher during install. Give each launcher a stable adjacent wasm file. +for tool in ffmpeg ffprobe; do + if [[ ! -s "${tool}_g.wasm" || ! -s "${PREFIX}/bin/${tool}.js" ]]; then + echo "error: ${tool} CLI was not built; expected ${tool}_g.wasm and ${PREFIX}/bin/${tool}.js" >&2 + exit 1 + fi + install -Dm755 "${tool}_g.wasm" "${PREFIX}/bin/${tool}.wasm" + sed -i "s/${tool}_g\\.wasm/${tool}.wasm/g" "${PREFIX}/bin/${tool}.js" + if [[ ! -s "${PREFIX}/bin/${tool}.wasm" ]]; then + echo "error: failed to install ${PREFIX}/bin/${tool}.wasm" >&2 + exit 1 + fi +done install -Dm644 "${RECIPE_DIR}/cmake/FFmpegConfig.cmake" \ "${PREFIX}/lib/cmake/FFmpeg/FFmpegConfig.cmake" diff --git a/recipes/recipes_emscripten/ffmpeg/build_tests.sh b/recipes/recipes_emscripten/ffmpeg/build_tests.sh index 0723989d19..87ca037861 100644 --- a/recipes/recipes_emscripten/ffmpeg/build_tests.sh +++ b/recipes/recipes_emscripten/ffmpeg/build_tests.sh @@ -6,6 +6,8 @@ echo "Building FFmpeg tests..." echo "==========================================" export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH:-}" +export CFLAGS="${CFLAGS:-}" +export LDFLAGS="${LDFLAGS:-}" mkdir -p build_tests cd build_tests @@ -20,6 +22,8 @@ emmake ninja echo "Running FFmpeg tests..." node test_ffmpeg.js +node "${PREFIX}/bin/ffmpeg.js" -version +node "${PREFIX}/bin/ffprobe.js" -version echo "==========================================" echo "All FFmpeg tests passed!" diff --git a/recipes/recipes_emscripten/ffmpeg/recipe.yaml b/recipes/recipes_emscripten/ffmpeg/recipe.yaml index 2eba89411b..be64aabcba 100644 --- a/recipes/recipes_emscripten/ffmpeg/recipe.yaml +++ b/recipes/recipes_emscripten/ffmpeg/recipe.yaml @@ -11,7 +11,7 @@ source: sha256: b6863adde98898f42602017462871b5f6333e65aec803fdd7a6308639c52edf3 build: - number: 0 + number: 1 script: build.sh requirements: @@ -33,6 +33,16 @@ tests: - libswresample.a - libavfilter.a - libavdevice.a + bin: + # Rattler adds .js and .wasm for Emscripten bin entries. + - ffmpeg + - ffprobe + files: + # Check both members of each Emscripten executable explicitly. + - bin/ffmpeg.js + - bin/ffmpeg.wasm + - bin/ffprobe.js + - bin/ffprobe.wasm include: - libavcodec/avcodec.h - libavformat/avformat.h From 2553e0691bbf0ae5df5e3537a603a7a9b81d9269 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Wed, 15 Jul 2026 10:58:16 +0200 Subject: [PATCH 2/3] split into several packages --- .../recipes_emscripten/ffmpeg/build_tests.sh | 15 +- recipes/recipes_emscripten/ffmpeg/recipe.yaml | 148 ++++++++++++------ 2 files changed, 109 insertions(+), 54 deletions(-) diff --git a/recipes/recipes_emscripten/ffmpeg/build_tests.sh b/recipes/recipes_emscripten/ffmpeg/build_tests.sh index 87ca037861..fa8519a3bb 100644 --- a/recipes/recipes_emscripten/ffmpeg/build_tests.sh +++ b/recipes/recipes_emscripten/ffmpeg/build_tests.sh @@ -5,6 +5,19 @@ echo "==========================================" echo "Building FFmpeg tests..." echo "==========================================" +test_type="${1:?usage: build_tests.sh {libs|cli}}" + +if [[ "${test_type}" == "cli" ]]; then + node "${PREFIX}/bin/ffmpeg.js" -version + node "${PREFIX}/bin/ffprobe.js" -version + exit 0 +fi + +if [[ "${test_type}" != "libs" ]]; then + echo "error: unknown test type: ${test_type}" >&2 + exit 2 +fi + export PKG_CONFIG_PATH="${PREFIX}/lib/pkgconfig:${PKG_CONFIG_PATH:-}" export CFLAGS="${CFLAGS:-}" export LDFLAGS="${LDFLAGS:-}" @@ -22,8 +35,6 @@ emmake ninja echo "Running FFmpeg tests..." node test_ffmpeg.js -node "${PREFIX}/bin/ffmpeg.js" -version -node "${PREFIX}/bin/ffprobe.js" -version echo "==========================================" echo "All FFmpeg tests passed!" diff --git a/recipes/recipes_emscripten/ffmpeg/recipe.yaml b/recipes/recipes_emscripten/ffmpeg/recipe.yaml index be64aabcba..297b037f08 100644 --- a/recipes/recipes_emscripten/ffmpeg/recipe.yaml +++ b/recipes/recipes_emscripten/ffmpeg/recipe.yaml @@ -2,67 +2,111 @@ context: name: ffmpeg version: 8.1.1 -package: - name: ${{ name }} +recipe: + name: ffmpeg version: ${{ version }} -source: - url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz - sha256: b6863adde98898f42602017462871b5f6333e65aec803fdd7a6308639c52edf3 - build: - number: 1 - script: build.sh + number: 2 -requirements: - build: - - ${{ compiler('c') }} - - ${{ compiler('cxx') }} - - make - - pkg-config - host: [] - run: [] +source: + - url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz + sha256: b6863adde98898f42602017462871b5f6333e65aec803fdd7a6308639c52edf3 -tests: - - package_contents: - lib: - - libavcodec.a - - libavformat.a - - libavutil.a - - libswscale.a - - libswresample.a - - libavfilter.a - - libavdevice.a - bin: - # Rattler adds .js and .wasm for Emscripten bin entries. - - ffmpeg - - ffprobe - files: - # Check both members of each Emscripten executable explicitly. - - bin/ffmpeg.js - - bin/ffmpeg.wasm - - bin/ffprobe.js - - bin/ffprobe.wasm - include: - - libavcodec/avcodec.h - - libavformat/avformat.h - - libavutil/avutil.h - - libswscale/swscale.h - - libswresample/swresample.h - - libavfilter/avfilter.h - - script: - - build_tests.sh +outputs: + - staging: + name: ffmpeg-build requirements: build: - ${{ compiler('c') }} - ${{ compiler('cxx') }} - - cmake - - ninja - - nodejs - files: - recipe: - - build_tests.sh - - tests/ + - make + - pkg-config + host: [] + build: + script: build.sh + + - package: + name: ffmpeg + version: ${{ version }} + inherit: ffmpeg-build + build: + files: + include: + - lib/libavcodec.a + - lib/libavformat.a + - lib/libavutil.a + - lib/libswscale.a + - lib/libswresample.a + - lib/libavfilter.a + - lib/libavdevice.a + - lib/pkgconfig/*.pc + - lib/cmake/FFmpeg/** + - include/** + tests: + - package_contents: + lib: + - libavcodec.a + - libavformat.a + - libavutil.a + - libswscale.a + - libswresample.a + - libavfilter.a + - libavdevice.a + include: + - libavcodec/avcodec.h + - libavformat/avformat.h + - libavutil/avutil.h + - libswscale/swscale.h + - libswresample/swresample.h + - libavfilter/avfilter.h + files: + - lib/cmake/FFmpeg/FFmpegConfig.cmake + - script: + - bash build_tests.sh libs + requirements: + build: + - ${{ compiler('c') }} + - ${{ compiler('cxx') }} + - cmake + - ninja + files: + recipe: + - build_tests.sh + - tests/ + + - package: + name: ffmpeg-cli + version: ${{ version }} + inherit: ffmpeg-build + build: + files: + include: + - bin/ffmpeg.js + - bin/ffmpeg.wasm + - bin/ffprobe.js + - bin/ffprobe.wasm + requirements: + run: + - ffmpeg =${{ version }} + tests: + - package_contents: + bin: + - ffmpeg + - ffprobe + files: + - bin/ffmpeg.js + - bin/ffmpeg.wasm + - bin/ffprobe.js + - bin/ffprobe.wasm + - script: + - bash build_tests.sh cli + requirements: + build: + - nodejs + files: + recipe: + - build_tests.sh about: homepage: https://ffmpeg.org/ From 0a9546e909bf071680ed193eff1d8021a3a5fdc3 Mon Sep 17 00:00:00 2001 From: Alexis Placet Date: Wed, 15 Jul 2026 13:58:59 +0200 Subject: [PATCH 3/3] fix --- recipes/recipes_emscripten/ffmpeg/build_tests.sh | 3 ++- recipes/recipes_emscripten/ffmpeg/recipe.yaml | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/recipes/recipes_emscripten/ffmpeg/build_tests.sh b/recipes/recipes_emscripten/ffmpeg/build_tests.sh index fa8519a3bb..8d428638a2 100644 --- a/recipes/recipes_emscripten/ffmpeg/build_tests.sh +++ b/recipes/recipes_emscripten/ffmpeg/build_tests.sh @@ -5,7 +5,8 @@ echo "==========================================" echo "Building FFmpeg tests..." echo "==========================================" -test_type="${1:?usage: build_tests.sh {libs|cli}}" +raw_test_type="${1:?usage: build_tests.sh libs or cli}" +test_type="${raw_test_type%\}}" if [[ "${test_type}" == "cli" ]]; then node "${PREFIX}/bin/ffmpeg.js" -version diff --git a/recipes/recipes_emscripten/ffmpeg/recipe.yaml b/recipes/recipes_emscripten/ffmpeg/recipe.yaml index acede8adf1..9a04e7f6b5 100644 --- a/recipes/recipes_emscripten/ffmpeg/recipe.yaml +++ b/recipes/recipes_emscripten/ffmpeg/recipe.yaml @@ -11,7 +11,7 @@ build: source: - url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz - sha256: b6863adde98898f42602017462871b5f6333e65aec803fdd7a6308639c52edf3 + sha256: 464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c outputs: - staging: