FFmpeg to WASM build setup + Vue app.

This commit is contained in:
Alf
2020-09-23 19:06:40 -07:00
commit 711903032c
20 changed files with 12826 additions and 0 deletions

77
Dockerfile Normal file
View File

@@ -0,0 +1,77 @@
FROM emscripten/emsdk as build
ARG FFMPEG_VERSION=4.3.1
ARG X264_VERSION=master
ARG PREFIX=/opt/ffmpeg
ARG MAKEFLAGS="-j4"
RUN apt-get update && apt-get install -y autoconf libtool build-essential
# libx264
RUN cd /tmp/ && \
wget https://code.videolan.org/videolan/x264/-/archive/master/x264-master.tar.gz && \
tar zxf x264-${X264_VERSION}.tar.gz
RUN cd /tmp/x264-${X264_VERSION} && \
emconfigure ./configure \
--prefix=${PREFIX} \
--host=i686-gnu \
--enable-static \
--disable-cli \
--disable-asm \
--extra-cflags="-s USE_PTHREADS=1"
RUN cd /tmp/x264-${X264_VERSION} && \
emmake make install-lib-static -j4
# Get ffmpeg source.
RUN cd /tmp/ && \
wget http://ffmpeg.org/releases/ffmpeg-${FFMPEG_VERSION}.tar.gz && \
tar zxf ffmpeg-${FFMPEG_VERSION}.tar.gz && rm ffmpeg-${FFMPEG_VERSION}.tar.gz
ARG CFLAGS="-s USE_PTHREADS -O3 -I${PREFIX}/include"
ARG LDFLAGS="$CFLAGS -L${PREFIX}/lib -s INITIAL_MEMORY=33554432"
# Compile ffmpeg.
RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \
emconfigure ./configure \
--prefix=${PREFIX} \
--target-os=none \
--arch=x86_32 \
--enable-cross-compile \
--disable-x86asm \
--disable-inline-asm \
--disable-stripping \
--disable-programs \
--disable-doc \
--enable-gpl \
--enable-libx264 \
--extra-cflags="$CFLAGS" \
--extra-cxxflags="$CFLAGS" \
--extra-ldflags="$LDFLAGS" \
--nm="llvm-nm -g" \
--ar=emar \
--as=llvm-as \
--ranlib=llvm-ranlib \
--cc=emcc \
--cxx=em++ \
--objcc=emcc \
--dep-cc=emcc
RUN cd /tmp/ffmpeg-${FFMPEG_VERSION} && \
emmake make -j4 && \
emmake make install
# RUN cd /build && \
# emcc -L/opt/ffmpeg/lib -I/opt/ffmpeg/include/ src/main.c \
# -s EXPORTED_FUNCTIONS='["_version", "_openfile"]' \
# -s EXTRA_EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory]" \
# -s INITIAL_MEMORY=268435456 \
# -lavcodec -lavformat -lavfilter -lavdevice -lswresample -lswscale -lavutil -lm -lx264 -pthread \
# -o ffmpeg-webtools.js
WORKDIR /build
COPY ./src/main.c /build/src/main.c
COPY ./Makefile /build/Makefile
# RUN make