Skip to content
Open
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
30 changes: 23 additions & 7 deletions recipes/recipes_emscripten/ffmpeg/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,44 @@ 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 \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are threads absolutely needed?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I can't compile the CLI without it

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does that mean the pthread symbols are only dragged into the binary or are the libs also have them?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the recipe to have two pacakges now, one for the libs and another one for the CLI. I can create two packages which don't share the same core and so have the libs without pthread and the CLI with it

--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 \
--enable-swscale --enable-swresample \
--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"
Expand Down
16 changes: 16 additions & 0 deletions recipes/recipes_emscripten/ffmpeg/build_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,23 @@ echo "=========================================="
echo "Building FFmpeg tests..."
echo "=========================================="

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
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:-}"

mkdir -p build_tests
cd build_tests
Expand Down
142 changes: 98 additions & 44 deletions recipes/recipes_emscripten/ffmpeg/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,111 @@ context:
name: ffmpeg
version: 8.1.2

package:
name: ${{ name }}
recipe:
name: ffmpeg
version: ${{ version }}

build:
number: 2

source:
url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz
sha256: 464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c
- url: https://ffmpeg.org/releases/${{ name }}-${{ version }}.tar.xz
sha256: 464beb5e7bf0c311e68b45ae2f04e9cc2af88851abb4082231742a74d97b524c

build:
number: 0
script: build.sh
outputs:
- staging:
name: ffmpeg-build
requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- make
- pkg-config
host: []
build:
script: build.sh

requirements:
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- make
- pkg-config
host: []
run: []
- 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/

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
- script:
- build_tests.sh
requirements:
- package:
name: ffmpeg-cli
version: ${{ version }}
inherit: ffmpeg-build
build:
- ${{ compiler('c') }}
- ${{ compiler('cxx') }}
- cmake
- ninja
- nodejs
files:
recipe:
- build_tests.sh
- tests/
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/
Expand Down