Closed pvitaliy84 closed 2 years ago
configure-ffmpeg.sh
...
FLAGS=(
"${FFMPEG_CONFIG_FLAGS_BASE[@]}"
--enable-nonfree # required by fdk-aac
--enable-libwavpack # enable libwavpack
--enable-libmp3lame # enable libmp3lame
--enable-libfdk-aac # enable libfdk-aac
--enable-libvorbis # enable libvorbis
--enable-libopus # enable opus
)
...
var.sh
...
FFMPEG_CONFIG_FLAGS_BASE=(
--target-os=none # use none to prevent any os specific configurations
--arch=x86_32 # use x86_32 to achieve minimal architectural optimization
--enable-cross-compile # enable cross compile
--disable-x86asm # disable x86 asm
--disable-inline-asm # disable inline asm
--disable-stripping # disable stripping
--disable-programs # disable programs build (incl. ffplay, ffprobe & ffmpeg)
--disable-doc # disable doc
--disable-debug # disable debug info, required by closure
--disable-runtime-cpudetect # disable runtime cpu detect
--disable-autodetect # disable external libraries auto detect
--disable-everything
--disable-network
--enable-small
--enable-protocol=file
--enable-ffmpeg
--enable-avcodec
--enable-avformat
--enable-swresample
--enable-avfilter
--enable-filter=aresample
--disable-swscale
--enable-muxer=mp3,ogg,wav,mp4,flac,pcm*
--enable-demuxer=mp3,ogg,wav,aac,flac,pcm*
--enable-encoder=libvorbis
--enable-decoder=mp3*,opus,libopus,vorbis,libvorbis,wavpack,adpcm_ima_wav,flac,aac*,libfdk_aac \
--enable-libmp3lame --enable-libvorbis --enable-libopus --enable-libfdk-aac --enable-nonfree \
--extra-cflags="$CFLAGS"
--extra-cxxflags="$CFLAGS"
--extra-ldflags="$LDFLAGS"
--pkg-config-flags="--static"
--nm="llvm-nm"
--ar=emar
--ranlib=emranlib
--cc=emcc
--cxx=em++
--objcc=emcc
--dep-cc=emcc
${EXTRA_FFMPEG_CONF_FLAGS-}
)
...
build-ffmpeg.sh
...
FLAGS=(
-I. -I./fftools -I$BUILD_DIR/include
-Llibavcodec -Llibavdevice -Llibavfilter -Llibavformat -Llibavresample -Llibavutil -Llibass -Llibpostproc -Llibswscale -Llibswresample -L$BUILD_DIR/lib
-Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lavutil -lm -lwavpack -lmp3lame -lfdk-aac -lvorbis -lvorbisenc -lvorbisfile -logg -lopus
fftools/ffmpeg_opt.c fftools/ffmpeg_filter.c fftools/ffmpeg_hw.c fftools/cmdutils.c fftools/ffmpeg.c
-s USE_SDL=2 # use SDL2
-s INVOKE_RUN=0 # not to run the main() in the beginning
-s EXIT_RUNTIME=1 # exit runtime after execution
-s MODULARIZE=1 # use modularized version to be more flexible
-s EXPORT_NAME="createFFmpegCore" # assign export name for browser
-s EXPORTED_FUNCTIONS="[_main]" # export main and proxy_main funcs
-s EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory]" # export preamble funcs
-s INITIAL_MEMORY=2146435072 # 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB
-s ASSERTIONS=1
--pre-js wasm/src/pre.js
--post-js wasm/src/post.js
$OPTIM_FLAGS
${EXTRA_FLAGS[@]}
)
...
Result: ffmpeg-core - 2.81Mb
But, error:
Uncaught ReferenceError: createFFmpegCore is not defined
How fix???
All works!!!
But: index.d.ts
export interface CreateFFmpegOptions {
mainName?: string;
/** path for ffmpeg-core.js script */
corePath?: string;
/** a boolean to turn on all logs, default is false */
log?: boolean;
/** a function to get log messages, a quick example is ({ message }) => console.log(message) */
logger?: LogCallback;
/** a function to trace the progress, a quick example is p => console.log(p) */
progress?: ProgressCallback;
}
createFFmpeg.js
Line #86:
ffmpeg = Core.cwrap('main', 'number', ['number', 'number']);
Line #171...
const exit = () => {
if (Core === null) {
throw NO_LOAD;
} else {
running = false;
try {
Core.exit(1);
} catch (e) {
console.log('catch core exit error', e);
}
Core = null;
ffmpeg = null;
runResolve = null;
}
};
...
I try this: #137
I need: 1) compile only audio:
2) Compile small size of the wasm.
My changes:
core-st.yaml
var.sh
configure-ffmpeg.sh
build-ffmpeg.sh
ERROR on build-ffmpeg:
Please, help me