You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ok="y"
local out=$(find . -name "*.o")
if [ -n "$out" ];then
echo -e "\033[31mThis is very long time operation!!!!!\033[0m"
echo -e "\033[31mRecompile FFmpeg???? [y/N]\033[0m"
read ok
fi
if [ "$ok" != "y" ];then popd;return;fi
if [ -d "$ff_build_dir" ];then
rm -r $ff_build_dir
fi
按照作者环境一步步走下来,在执行emconfigure后各种头文件定义错误。死活make不过
将emsdk升级到最高版本:我目前的版本为emcc(version:3.1.29) ,然后即可make编译通过(可以修改脚本里面的make为 make -j 16)
最后执行./build_decoder_wasm.sh又报错:
需要把 “int initBuffer(width, height)” 改为 “int initBuffer(int width, int height)” 最后即可编译生成 .wasm .js
但是上面的方法最终运行不了,无奈~没学过js,只好回头来解决编译问题
最终我将编译步骤写成了一个完整的脚本 ,它可以完美的帮你一键编译完成,脚本如下:
`
#!/bin/bash
ff_version="ffmpeg-4.1.10"
work_path="decoder_wasm"
ff_build_dir="ffmpeg"
main(){
initializaiton_emsdk
get_ffmpeg
pull_decoder_wasm
emscripten_build_ffmpeg
update_video_js
emscripten_build_c
}
pull_decoder_wasm(){
if [ ! -d decoder_wasm ];then
git clone https://github.com/goldvideo/decoder_wasm decoder_wasm
fi
}
intstall_emsdk(){
pushd emsdk
./emsdk install 1.38.45
./emsdk activate 1.38.45
source ./emsdk_env.sh
popd
}
initializaiton_emsdk(){
obj=emcc
if [ ! -x "$(command -v $obj)" ];then
echo "$obj installing ....."
if [ ! -d emsdk ];then
git clone https://github.com/emscripten-core/emsdk.git emsdk
intstall_emsdk
fi
fi
local version=$(emcc -v 2>&1 | grep "1......" | awk '{printf $10}')
echo -e "\033[31m$version\033[0m"
if [ "$version" != "1.38.45" ];then
intstall_emsdk
fi
local version=$(emcc -v 2>&1 | grep "1......" | awk '{printf $10}')
echo $version
if [ "$version" != "1.38.45" ];then
echo -e "\033[31mexit env error!!!\033[0m";exit
fi
}
get_ffmpeg(){
if [ ! -d "$ff_version" ];then
if [ ! -f "$ff_version.tar.bz2" ];then
wget https://ffmpeg.org/releases/${ff_version}.tar.bz2
tar -xjvf ${ff_version}.tar.bz2
fi
fi
}
emscripten_build_ffmpeg(){
pushd $ff_version
ok="y"
local out=$(find . -name "*.o")
if [ -n "$out" ];then
echo -e "\033[31mThis is very long time operation!!!!!\033[0m"
echo -e "\033[31mRecompile FFmpeg???? [y/N]\033[0m"
read ok
fi
if [ "$ok" != "y" ];then popd;return;fi
if [ -d "$ff_build_dir" ];then
rm -r $ff_build_dir
fi
make clean
emconfigure ./configure --cc="emcc" --cxx="em++" --ar="emar" --prefix=$(pwd)/../${work_path}/${ff_build_dir} --enable-cross-compile --target-os=none --arch=x86_32 --cpu=generic
--enable-gpl --enable-version3 --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 --disable-pthreads --disable-w32threads --ranlib=emranlib
--enable-decoder=hevc --enable-parser=hevc
--enable-decoder=h264 --enable-parser=h264
make -j 16
make install
popd
}
emscripten_build_c(){
types="264_265"
pushd $work_path
if [ -d dist ];then rm -rf dist;fi
mkdir dist
export TOTAL_MEMORY=67108864
export EXPORTED_FUNCTIONS="[
'_openDecoder',
'_flushDecoder',
'_closeDecoder',
'_decodeData',
'_main'
]"
echo "Running Emscripten..."
emcc decode_video.c ${ff_build_dir}/lib/libavcodec.a ${ff_build_dir}/lib/libavutil.a ${ff_build_dir}/lib/libswscale.a
-O2
-I "${ff_build_dir}/include"
-s WASM=1
-s TOTAL_MEMORY=${TOTAL_MEMORY}
-s EXPORTED_FUNCTIONS="${EXPORTED_FUNCTIONS}"
-s EXTRA_EXPORTED_RUNTIME_METHODS="['addFunction']"
-s RESERVED_FUNCTION_POINTERS=20
-s FORCE_FILESYSTEM=1
-w -o dist/libffmpeg_${types}.js
echo "Finished Build . output file in dist:
ls dist
"echo -e "\033[31mAre you need into $work_path execution 'npm install && npm start' ?\033[0m"
}
update_video_js(){$file | grep -n "$ {flag}" | awk -F ":" '{print $1}')
pushd $work_path
git restore test/video.js
local flag="displayVideoFrame(obj);"
local file="test/video.js"
line=$(cat
((line++))
echo $line
sed -i "" "${line}d" $file
sed -i "" "/${flag}/a\
},'viiiiiiiii');
" $file
popd
}
main
`
脚本除了首次执行外,之后的执行过程中会有一次交互操作,"Recompile FFmpeg???? [y/N]" 如果需要再次编译则手动输入 ”y“来确认编译ffmpeg,因为这个一项耗时操作,为了防止误操作所以我将它单独分出来执行。 最后执行npm install && npm start就可以完成部署了。。。。已经在Mac OS (Intel) 、 Ubantu 18上面完美一键搭建完成。
The text was updated successfully, but these errors were encountered: