Skip to content

WIP: Wasm/emscripten contrib ffmpeg : Add wasm / emscripten support for ffmpeg contrib

Mehdi Sabwat requested to merge wasm/emscripten-contrib-ffmpeg into master

The current configuration does not enable cross compilation for wasm using emscripten. In order to get a wasm library that we can link to our libvlc.wasm we need to :

  • Add emscripten target and toolchain variables for all the contribs
  • Patch ffmpeg to prevent configuration errors :
ifdef HAVE_EMSCRIPTEN
FFMPEGCONF+=--target-os=emscripten --arch=wasm32 --ranlib=emranlib \
	    --extra-ldflags="-pthread" --extra-ldexeflags="-pthread"
endif

The extra-ld flag is due to the fact that most of the configuration tests are run in two steps:

  1. compilation with -pthread
  2. linking without -pthread This causes a crash and makes the test fail despite its success.

We need to enable -pthread in all the libvlc build, because we cannot link to -pthread enabled objects without specifying it in all the objects.

There is also the fact that emcc -o exe is not standard and does not produce an executable so we need to add :

exesuf() {
    case $1 in
        mingw32*|mingw64*|win32|win64|cygwin*|*-dos|freedos|opendos|os/2*|symbian) echo .exe ;;
+	emscripten) echo .js ;;
    esac
}
  • Work around an LLVM bug, that is reported here.

Testing:

mkdir contrib-emscripten
cd contrib-emscripten
../bootstrap --disable-disc --disable-gpl --disable-sout --disable-network --host=wasm32-unknown-emscripten --build=x86_64-linux
emmake make .ffmpeg

emmake is available with the emscripten toolchain.

emsdk install latest-upstream is advised to get the latest toolchain changes.

Edited by Mehdi Sabwat

Merge request reports

Loading