emscripten emcc ffmpeg

1. emscripten

Emscripten is a complete compiler toolchain to WebAssembly, using LLVM, with a special focus on speed, size, and the Web platform.

https://emscripten.org/docs/getting_started/downloads.html

Get the emsdk repo
 git clone https://github.com/emscripten-core/emsdk.git
Enter that directory
 cd emsdk
Fetch the latest version of the emsdk (not needed the first time you clone)
 git pull
Download and install the latest SDK tools.
 ./emsdk install latest	or   ./emsdk install 1.38.45
Make the “latest” SDK “active” for the current user. (writes .emscripten file)
 ./emsdk activate latest    or   ./emsdk activate 1.38.45
Activate PATH and other environment variables in the current terminal
 source ./emsdk_env.sh

2. emcc ffmpeg -> libavcodec.a libavutil.a libswscale.a

https://ffmpeg.org/

Get the ffmpeg repo
 git clone git://source.ffmpeg.org/ffmpeg.git
Enter that directory
 cd ffmpeg
Config
 emconfigure ./configure --cc=emcc --cxx=em++ --ar=emar  --ranlib=emranlib --prefix=$(path) --cpu=generic --disable-avdevice --disable-avformat --disable-swresample --disable-postproc --disable-avfilter --disable-programs --disable-logging --disable-everything --disable-ffplay --disable-ffprobe --disable-asm --disable-doc --disable-devices --disable-network --disable-hwaccels --disable-parsers --disable-bsfs --disable-debug --disable-protocols --disable-indevs --disable-outdevs --enable-decoder=hevc --enable-parser=hevc --enable-decoder=h264  --enable-parser=h264
make
 make
install
 make install

3. C/C++

Use ffmpeg to implement your functions and provide interfaces

4. emcc ffmpeg -> libffmpeg.wasm libffmpeg.js

shell

export TOTAL_MEMORY=67108864
export EXPORTED_FUNCTIONS=“[‘_function1’ ,‘_function2’, ‘_function3’,‘_function4’,‘_main’,‘_malloc’,‘_free’]”

emcc ****.c ./dist/lib/libavcodec.a ./dist/lib/libavutil.a ./dist/lib/libswscale.a
-O2
-I “./dist/include”
-s WASM=1
-s TOTAL_MEMORY= T O T A L M E M O R Y   − s E X P O R T E D F U N C T I O N S = " {TOTAL_MEMORY} \ -s EXPORTED_FUNCTIONS=" TOTALMEMORY sEXPORTEDFUNCTIONS="{EXPORTED_FUNCTIONS}"
-s EXPORTED_RUNTIME_METHODS=“[‘addFunction’]”
-s RESERVED_FUNCTION_POINTERS=14
-s FORCE_FILESYSTEM=1
-o dist/libffmpeg.js

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值