ffmpegwasm / ffmpeg.wasm

FFmpeg for browser, powered by WebAssembly
https://ffmpegwasm.netlify.app
MIT License
14.47k stars 852 forks source link

Need small (SingleThread) ffmpeg-core.wasm #312

Closed pvitaliy84 closed 2 years ago

pvitaliy84 commented 2 years ago

I try this: #137

I need: 1) compile only audio:

2) Compile small size of the wasm.

My changes:

core-st.yaml

name: Build FFmpeg.wasm (Single Thread)
on:
  push:
    branches:
      - n4.3.1-wasm
  pull_request:
    branches:
      - n4.3.1-wasm

env:
  FFMPEG_ST: yes
  DIST_PATH: wasm/packages/core-st/dist
  CACHE_KEY_PREFIX: ffmpeg.wasm-core-st
  # EM_VERSION: 2.0.8
  # EM_CACHE_FOLDER: 'emsdk-cache'

jobs:
  build-libs:
    strategy:
      max-parallel: 1
      matrix:
        script:
          - build-wavpack
          - build-lame
          - build-ogg
          - build-vorbis
          - build-opus
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Get commit hash
        id: get-commit-hash
        run: |
          echo "::set-output name=hash::$(git rev-parse --short HEAD)"
      - name: Cache libs
        uses: actions/cache@v2
        with:
          path: |
            build
            wasm/cache
          key: ${{ env.CACHE_KEY_PREFIX }}-${{ steps.get-commit-hash.outputs.hash }}-${{ matrix.script }}
          restore-keys: |
            ${{ env.CACHE_KEY_PREFIX }}-${{ steps.get-commit-hash.outputs.hash }}-
      - name: List cached libs
        run: ls -R build || true
      - name: Build FFMpeg Libs
        run: bash build-with-docker.sh install-deps ${{ matrix.script }}
  build-ffmpeg:
    runs-on: ubuntu-latest
    needs: build-libs
    steps:
      - uses: actions/checkout@v2
        with:
          submodules: recursive
      - name: Get commit hash
        id: get-commit-hash
        run: |
          echo "::set-output name=hash::$(git rev-parse --short HEAD)"
      - name: Cache multiple paths
        uses: actions/cache@v2
        env:
          GIT_HASH: $(git rev-parse --short HEAD)
        with:
          path: |
            build
            wasm/cache
          key: ${{ env.CACHE_KEY_PREFIX }}-${{ steps.get-commit-hash.outputs.hash }}-ffmpeg
          restore-keys: |
            ${{ env.CACHE_KEY_PREFIX }}-${{ steps.get-commit-hash.outputs.hash }}-
      - name: List cached libs
        run: ls -R build || true
      - name: Build FFMpeg
        run: |
          bash build-with-docker.sh \
            install-deps \
            configure-ffmpeg \
            build-ffmpeg
      - uses: actions/upload-artifact@master
        with:
          name: ffmpeg-core
          path: ${{ env.DIST_PATH }}

var.sh

#!/bin/bash
#
# Common variables for all scripts

set -euo pipefail

# Include llvm binaries
export PATH=$PATH:$EMSDK/upstream/bin

# if yes, we are building a single thread version of
# ffmpeg.wasm-core, which is slow but compatible with
# most browsers as there is no SharedArrayBuffer.
FFMPEG_ST=${FFMPEG_ST:-no}

# Root directory
ROOT_DIR=$PWD

# Directory to install headers and libraries
BUILD_DIR=$ROOT_DIR/build

# Directory to look for pkgconfig files
EM_PKG_CONFIG_PATH=$BUILD_DIR/lib/pkgconfig

# Toolchain file path for cmake
TOOLCHAIN_FILE=$EMSDK/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake

# Flags for code optimization, focus on speed instead
# of size
OPTIM_FLAGS="-O3"

if [[ "$OSTYPE" == "linux-gnu"* ]]; then
  # Use closure complier only in linux environment
  OPTIM_FLAGS="$OPTIM_FLAGS --closure 1"
fi

# Unset OPTIM_FLAGS can speed up build
# OPTIM_FLAGS=""

CFLAGS_BASE="$OPTIM_FLAGS -I$BUILD_DIR/include"
CFLAGS="$CFLAGS_BASE -s USE_PTHREADS=1"

if [[ "$FFMPEG_ST" == "yes" ]]; then
  CFLAGS="$CFLAGS_BASE"
  EXTRA_FFMPEG_CONF_FLAGS="--disable-pthreads --disable-w32threads --disable-os2threads"
fi

export CFLAGS=$CFLAGS
export CXXFLAGS=$CFLAGS
export LDFLAGS="$CFLAGS -L$BUILD_DIR/lib"
export STRIP="llvm-strip"
export EM_PKG_CONFIG_PATH=$EM_PKG_CONFIG_PATH

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
  --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-}
)

echo "EMSDK=$EMSDK"
echo "FFMPEG_ST=$FFMPEG_ST"
echo "CFLAGS(CXXFLAGS)=$CFLAGS"
echo "BUILD_DIR=$BUILD_DIR"

configure-ffmpeg.sh

#!/bin/bash

set -euo pipefail
source $(dirname $0)/var.sh

FLAGS=(
  "${FFMPEG_CONFIG_FLAGS_BASE[@]}"
  # --enable-gpl            # required by x264
  # --enable-nonfree        # required by fdk-aac
  # --enable-zlib           # enable zlib
  # --enable-libx264        # enable x264
  # --enable-libx265        # enable x265
  # --enable-libvpx         # enable libvpx / webm
  --enable-libwavpack     # enable libwavpack
  --enable-libmp3lame     # enable libmp3lame
  # --enable-libfdk-aac     # enable libfdk-aac
  # --enable-libtheora      # enable libtheora
  --enable-libvorbis      # enable libvorbis
  # --enable-libfreetype    # enable freetype
  --enable-libopus        # enable opus
  # --enable-libwebp        # enable libwebp
  # --enable-libass         # enable libass
  # --enable-libfribidi     # enable libfribidi
  # --enable-libaom         # enable libaom
)
echo "FFMPEG_CONFIG_FLAGS=${FLAGS[@]}"
emconfigure ./configure "${FLAGS[@]}"

build-ffmpeg.sh

#!/bin/bash

set -eo pipefail
source $(dirname $0)/var.sh

if [[ "$FFMPEG_ST" != "yes" ]]; then
  mkdir -p wasm/packages/core/dist
  EXTRA_FLAGS=(
    -pthread
    -s USE_PTHREADS=1                             # enable pthreads support
    -s PROXY_TO_PTHREAD=1                         # detach main() from browser/UI main thread
    -o wasm/packages/core/dist/ffmpeg-core.js
  )
else
  mkdir -p wasm/packages/core-st/dist
  EXTRA_FLAGS=(
    -o wasm/packages/core-st/dist/ffmpeg-core.js
  )
fi
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
  -lavutil -lm -lwavpack -lmp3lame -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
  --pre-js wasm/src/pre.js
  --post-js wasm/src/post.js
  $OPTIM_FLAGS
  ${EXTRA_FLAGS[@]}
)

echo "FFMPEG_EM_FLAGS=${FLAGS[@]}"
emmake make -j
emcc "${FLAGS[@]}"

ERROR on build-ffmpeg:

error: undefined symbol: av_bsf_free (referenced by top-level compiled C/C++ code)
warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
warning: _av_bsf_free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_get_by_name (referenced by top-level compiled C/C++ code)
warning: _av_bsf_get_by_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_get_class (referenced by top-level compiled C/C++ code)
warning: _av_bsf_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_init (referenced by top-level compiled C/C++ code)
warning: _av_bsf_init may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_iterate (referenced by top-level compiled C/C++ code)
warning: _av_bsf_iterate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_list_parse_str (referenced by top-level compiled C/C++ code)
warning: _av_bsf_list_parse_str may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_receive_packet (referenced by top-level compiled C/C++ code)
warning: _av_bsf_receive_packet may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_bsf_send_packet (referenced by top-level compiled C/C++ code)
warning: _av_bsf_send_packet may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_channel_layout (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_channel_layout may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_channels (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_channels may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_format (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_format may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_frame_flags (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_frame_flags may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_frame_rate (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_frame_rate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_h (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_h may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_hw_frames_ctx (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_hw_frames_ctx may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_sample_aspect_ratio (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_sample_aspect_ratio may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_sample_rate (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_sample_rate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_time_base (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_time_base may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_type (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_type may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_get_w (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_get_w may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersink_set_frame_size (referenced by top-level compiled C/C++ code)
warning: _av_buffersink_set_frame_size may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersrc_add_frame (referenced by top-level compiled C/C++ code)
warning: _av_buffersrc_add_frame may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersrc_add_frame_flags (referenced by top-level compiled C/C++ code)
warning: _av_buffersrc_add_frame_flags may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersrc_close (referenced by top-level compiled C/C++ code)
warning: _av_buffersrc_close may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersrc_get_nb_failed_requests (referenced by top-level compiled C/C++ code)
warning: _av_buffersrc_get_nb_failed_requests may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersrc_parameters_alloc (referenced by top-level compiled C/C++ code)
warning: _av_buffersrc_parameters_alloc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_buffersrc_parameters_set (referenced by top-level compiled C/C++ code)
warning: _av_buffersrc_parameters_set may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_codec_get_id (referenced by top-level compiled C/C++ code)
warning: _av_codec_get_id may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_codec_get_tag2 (referenced by top-level compiled C/C++ code)
warning: _av_codec_get_tag2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_codec_is_decoder (referenced by top-level compiled C/C++ code)
warning: _av_codec_is_decoder may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_codec_is_encoder (referenced by top-level compiled C/C++ code)
warning: _av_codec_is_encoder may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_codec_iterate (referenced by top-level compiled C/C++ code)
warning: _av_codec_iterate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_demuxer_iterate (referenced by top-level compiled C/C++ code)
warning: _av_demuxer_iterate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_dump_format (referenced by top-level compiled C/C++ code)
warning: _av_dump_format may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_filename_number_test (referenced by top-level compiled C/C++ code)
warning: _av_filename_number_test may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_filter_iterate (referenced by top-level compiled C/C++ code)
warning: _av_filter_iterate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_find_input_format (referenced by top-level compiled C/C++ code)
warning: _av_find_input_format may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_get_audio_frame_duration (referenced by top-level compiled C/C++ code)
warning: _av_get_audio_frame_duration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_get_exact_bits_per_sample (referenced by top-level compiled C/C++ code)
warning: _av_get_exact_bits_per_sample may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_guess_codec (referenced by top-level compiled C/C++ code)
warning: _av_guess_codec may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_guess_format (referenced by top-level compiled C/C++ code)
warning: _av_guess_format may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_guess_frame_rate (referenced by top-level compiled C/C++ code)
warning: _av_guess_frame_rate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_init_packet (referenced by top-level compiled C/C++ code)
warning: _av_init_packet may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_input_audio_device_next (referenced by top-level compiled C/C++ code)
warning: _av_input_audio_device_next may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_input_video_device_next (referenced by top-level compiled C/C++ code)
warning: _av_input_video_device_next may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_interleaved_write_frame (referenced by top-level compiled C/C++ code)
warning: _av_interleaved_write_frame may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_muxer_iterate (referenced by top-level compiled C/C++ code)
warning: _av_muxer_iterate may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_new_program (referenced by top-level compiled C/C++ code)
warning: _av_new_program may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_output_audio_device_next (referenced by top-level compiled C/C++ code)
warning: _av_output_audio_device_next may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_output_video_device_next (referenced by top-level compiled C/C++ code)
warning: _av_output_video_device_next may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_get_side_data (referenced by top-level compiled C/C++ code)
warning: _av_packet_get_side_data may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_make_refcounted (referenced by top-level compiled C/C++ code)
warning: _av_packet_make_refcounted may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_move_ref (referenced by top-level compiled C/C++ code)
warning: _av_packet_move_ref may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_new_side_data (referenced by top-level compiled C/C++ code)
warning: _av_packet_new_side_data may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_ref (referenced by top-level compiled C/C++ code)
warning: _av_packet_ref may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_rescale_ts (referenced by top-level compiled C/C++ code)
warning: _av_packet_rescale_ts may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_packet_unref (referenced by top-level compiled C/C++ code)
warning: _av_packet_unref may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_pkt_dump_log2 (referenced by top-level compiled C/C++ code)
warning: _av_pkt_dump_log2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_program_add_stream_index (referenced by top-level compiled C/C++ code)
warning: _av_program_add_stream_index may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_read_frame (referenced by top-level compiled C/C++ code)
warning: _av_read_frame may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_sdp_create (referenced by top-level compiled C/C++ code)
warning: _av_sdp_create may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_stream_get_codec_timebase (referenced by top-level compiled C/C++ code)
warning: _av_stream_get_codec_timebase may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_stream_get_end_pts (referenced by top-level compiled C/C++ code)
warning: _av_stream_get_end_pts may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_stream_get_parser (referenced by top-level compiled C/C++ code)
warning: _av_stream_get_parser may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_stream_get_side_data (referenced by top-level compiled C/C++ code)
warning: _av_stream_get_side_data may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_stream_new_side_data (referenced by top-level compiled C/C++ code)
warning: _av_stream_new_side_data may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: av_write_trailer (referenced by top-level compiled C/C++ code)
warning: _av_write_trailer may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_alloc_context3 (referenced by top-level compiled C/C++ code)
warning: _avcodec_alloc_context3 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_close (referenced by top-level compiled C/C++ code)
warning: _avcodec_close may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_configuration (referenced by top-level compiled C/C++ code)
warning: _avcodec_configuration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_copy_context (referenced by top-level compiled C/C++ code)
warning: _avcodec_copy_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_decode_subtitle2 (referenced by top-level compiled C/C++ code)
warning: _avcodec_decode_subtitle2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_default_get_buffer2 (referenced by top-level compiled C/C++ code)
warning: _avcodec_default_get_buffer2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_descriptor_get (referenced by top-level compiled C/C++ code)
warning: _avcodec_descriptor_get may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_descriptor_get_by_name (referenced by top-level compiled C/C++ code)
warning: _avcodec_descriptor_get_by_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_descriptor_next (referenced by top-level compiled C/C++ code)
warning: _avcodec_descriptor_next may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_encode_subtitle (referenced by top-level compiled C/C++ code)
warning: _avcodec_encode_subtitle may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_find_best_pix_fmt_of_2 (referenced by top-level compiled C/C++ code)
warning: _avcodec_find_best_pix_fmt_of_2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_find_decoder (referenced by top-level compiled C/C++ code)
warning: _avcodec_find_decoder may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_find_decoder_by_name (referenced by top-level compiled C/C++ code)
warning: _avcodec_find_decoder_by_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_find_encoder (referenced by top-level compiled C/C++ code)
warning: _avcodec_find_encoder may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_find_encoder_by_name (referenced by top-level compiled C/C++ code)
warning: _avcodec_find_encoder_by_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_flush_buffers (referenced by top-level compiled C/C++ code)
warning: _avcodec_flush_buffers may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_free_context (referenced by top-level compiled C/C++ code)
warning: _avcodec_free_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_get_class (referenced by top-level compiled C/C++ code)
warning: _avcodec_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_get_hw_config (referenced by top-level compiled C/C++ code)
warning: _avcodec_get_hw_config may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_get_name (referenced by top-level compiled C/C++ code)
warning: _avcodec_get_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_open2 (referenced by top-level compiled C/C++ code)
warning: _avcodec_open2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_parameters_alloc (referenced by top-level compiled C/C++ code)
warning: _avcodec_parameters_alloc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_parameters_copy (referenced by top-level compiled C/C++ code)
warning: _avcodec_parameters_copy may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_parameters_free (referenced by top-level compiled C/C++ code)
warning: _avcodec_parameters_free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_parameters_from_context (referenced by top-level compiled C/C++ code)
warning: _avcodec_parameters_from_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_parameters_to_context (referenced by top-level compiled C/C++ code)
warning: _avcodec_parameters_to_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_receive_frame (referenced by top-level compiled C/C++ code)
warning: _avcodec_receive_frame may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_receive_packet (referenced by top-level compiled C/C++ code)
warning: _avcodec_receive_packet may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_send_frame (referenced by top-level compiled C/C++ code)
warning: _avcodec_send_frame may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_send_packet (referenced by top-level compiled C/C++ code)
warning: _avcodec_send_packet may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avcodec_version (referenced by top-level compiled C/C++ code)
warning: _avcodec_version may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avdevice_configuration (referenced by top-level compiled C/C++ code)
warning: _avdevice_configuration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avdevice_free_list_devices (referenced by top-level compiled C/C++ code)
warning: _avdevice_free_list_devices may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avdevice_list_input_sources (referenced by top-level compiled C/C++ code)
warning: _avdevice_list_input_sources may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avdevice_list_output_sinks (referenced by top-level compiled C/C++ code)
warning: _avdevice_list_output_sinks may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avdevice_register_all (referenced by top-level compiled C/C++ code)
warning: _avdevice_register_all may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avdevice_version (referenced by top-level compiled C/C++ code)
warning: _avdevice_version may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_configuration (referenced by top-level compiled C/C++ code)
warning: _avfilter_configuration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_get_by_name (referenced by top-level compiled C/C++ code)
warning: _avfilter_get_by_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_get_class (referenced by top-level compiled C/C++ code)
warning: _avfilter_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_alloc (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_alloc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_alloc_filter (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_alloc_filter may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_config (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_config may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_create_filter (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_create_filter may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_free (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_parse2 (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_parse2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_queue_command (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_queue_command may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_request_oldest (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_request_oldest may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_send_command (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_send_command may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_graph_set_auto_convert (referenced by top-level compiled C/C++ code)
warning: _avfilter_graph_set_auto_convert may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_init_str (referenced by top-level compiled C/C++ code)
warning: _avfilter_init_str may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_inout_free (referenced by top-level compiled C/C++ code)
warning: _avfilter_inout_free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_link (referenced by top-level compiled C/C++ code)
warning: _avfilter_link may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_pad_count (referenced by top-level compiled C/C++ code)
warning: _avfilter_pad_count may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_pad_get_name (referenced by top-level compiled C/C++ code)
warning: _avfilter_pad_get_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_pad_get_type (referenced by top-level compiled C/C++ code)
warning: _avfilter_pad_get_type may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avfilter_version (referenced by top-level compiled C/C++ code)
warning: _avfilter_version may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_alloc_context (referenced by top-level compiled C/C++ code)
warning: _avformat_alloc_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_alloc_output_context2 (referenced by top-level compiled C/C++ code)
warning: _avformat_alloc_output_context2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_close_input (referenced by top-level compiled C/C++ code)
warning: _avformat_close_input may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_configuration (referenced by top-level compiled C/C++ code)
warning: _avformat_configuration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_find_stream_info (referenced by top-level compiled C/C++ code)
warning: _avformat_find_stream_info may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_free_context (referenced by top-level compiled C/C++ code)
warning: _avformat_free_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_get_class (referenced by top-level compiled C/C++ code)
warning: _avformat_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_match_stream_specifier (referenced by top-level compiled C/C++ code)
warning: _avformat_match_stream_specifier may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_network_deinit (referenced by top-level compiled C/C++ code)
warning: _avformat_network_deinit may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_network_init (referenced by top-level compiled C/C++ code)
warning: _avformat_network_init may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_new_stream (referenced by top-level compiled C/C++ code)
warning: _avformat_new_stream may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_open_input (referenced by top-level compiled C/C++ code)
warning: _avformat_open_input may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_query_codec (referenced by top-level compiled C/C++ code)
warning: _avformat_query_codec may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_seek_file (referenced by top-level compiled C/C++ code)
warning: _avformat_seek_file may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_transfer_internal_stream_timing_info (referenced by top-level compiled C/C++ code)
warning: _avformat_transfer_internal_stream_timing_info may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_version (referenced by top-level compiled C/C++ code)
warning: _avformat_version may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avformat_write_header (referenced by top-level compiled C/C++ code)
warning: _avformat_write_header may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_check (referenced by top-level compiled C/C++ code)
warning: _avio_check may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_close (referenced by top-level compiled C/C++ code)
warning: _avio_close may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_close_dyn_buf (referenced by top-level compiled C/C++ code)
warning: _avio_close_dyn_buf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_closep (referenced by top-level compiled C/C++ code)
warning: _avio_closep may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_enum_protocols (referenced by top-level compiled C/C++ code)
warning: _avio_enum_protocols may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_find_protocol_name (referenced by top-level compiled C/C++ code)
warning: _avio_find_protocol_name may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_flush (referenced by top-level compiled C/C++ code)
warning: _avio_flush may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_open (referenced by top-level compiled C/C++ code)
warning: _avio_open may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_open2 (referenced by top-level compiled C/C++ code)
warning: _avio_open2 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_open_dyn_buf (referenced by top-level compiled C/C++ code)
warning: _avio_open_dyn_buf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_print_string_array (referenced by top-level compiled C/C++ code)
warning: _avio_print_string_array may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_printf (referenced by top-level compiled C/C++ code)
warning: _avio_printf may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_protocol_get_class (referenced by top-level compiled C/C++ code)
warning: _avio_protocol_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_r8 (referenced by top-level compiled C/C++ code)
warning: _avio_r8 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_read (referenced by top-level compiled C/C++ code)
warning: _avio_read may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_seek (referenced by top-level compiled C/C++ code)
warning: _avio_seek may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_size (referenced by top-level compiled C/C++ code)
warning: _avio_size may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_w8 (referenced by top-level compiled C/C++ code)
warning: _avio_w8 may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avio_write (referenced by top-level compiled C/C++ code)
warning: _avio_write may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: avsubtitle_free (referenced by top-level compiled C/C++ code)
warning: _avsubtitle_free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swr_alloc (referenced by top-level compiled C/C++ code)
warning: _swr_alloc may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swr_free (referenced by top-level compiled C/C++ code)
warning: _swr_free may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swr_get_class (referenced by top-level compiled C/C++ code)
warning: _swr_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swresample_configuration (referenced by top-level compiled C/C++ code)
warning: _swresample_configuration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swresample_version (referenced by top-level compiled C/C++ code)
warning: _swresample_version may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: sws_alloc_context (referenced by top-level compiled C/C++ code)
warning: _sws_alloc_context may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: sws_freeContext (referenced by top-level compiled C/C++ code)
warning: _sws_freeContext may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: sws_get_class (referenced by top-level compiled C/C++ code)
warning: _sws_get_class may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: sws_isSupportedInput (referenced by top-level compiled C/C++ code)
warning: _sws_isSupportedInput may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: sws_isSupportedOutput (referenced by top-level compiled C/C++ code)
warning: _sws_isSupportedOutput may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swscale_configuration (referenced by top-level compiled C/C++ code)
warning: _swscale_configuration may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: swscale_version (referenced by top-level compiled C/C++ code)
warning: _swscale_version may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/emsdk/node/14.15.5_64bit/bin/node /emsdk/upstream/emscripten/src/compiler.js /tmp/tmpadxazvty.txt' failed (returned 1)
Error: Process completed with exit code 1.

Please, help me

pvitaliy84 commented 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???

pvitaliy84 commented 2 years ago

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;
    }
  };
...