Commit c1a69aae authored by Linshizhi's avatar Linshizhi

update

parent fc687dec
[submodule "lib/ffmpeg.protos"]
path = lib/ffmpeg.protos
url = git@gitlab.ilaihua.com:linshizhi/ffmpeg.sharedmemoryproto.git
[submodule "lib/ffmpeg.wasm-core"] [submodule "lib/ffmpeg.wasm-core"]
path = lib/ffmpeg.wasm-core path = lib/ffmpeg.wasm-core
url = git@gitlab.ilaihua.com:linshizhi/ffmpeg.wasm-core.git url = git@gitlab.ilaihua.com:linshizhi/ffmpeg.wasm-core.git
ffmpeg.protos @ ed4e7ded
Subproject commit ed4e7ded6e361f8a6ac9e0adfd31cd7e75aed157
...@@ -24,7 +24,7 @@ self.importScripts('defs.js'); ...@@ -24,7 +24,7 @@ self.importScripts('defs.js');
// Load wasm encoder // Load wasm encoder
self.importScripts('paraencoder.js'); self.importScripts('paraencoder.js');
createParaEncoder().then(m => { createEncoder().then(m => {
encoder = m; encoder = m;
}); });
......
...@@ -27,8 +27,8 @@ let muxBuffer = null; ...@@ -27,8 +27,8 @@ let muxBuffer = null;
self.importScripts('defs.js'); self.importScripts('defs.js');
// Load wasm encoder // Load wasm encoder
self.importScripts('./paraencoder.js'); self.importScripts('./paramuxer.js');
createParaEncoder().then(m => { createMuxer().then(m => {
muxer = m; muxer = m;
}); });
...@@ -129,7 +129,7 @@ async function step() { ...@@ -129,7 +129,7 @@ async function step() {
// Check EOF // Check EOF
let flag = chn.readPriv(); let flag = chn.readPriv();
if (flag & PRIV_FLAGS.EOF) { if (flag & PRIV_FLAGS.EOF) {
console.log("MUXER: EOF " + i) console.log("MUXER: EOF " + i);
muxer._eof(i); muxer._eof(i);
++eofCount; ++eofCount;
......
...@@ -173,15 +173,16 @@ export class H264EncWWGroup extends WWGroup { ...@@ -173,15 +173,16 @@ export class H264EncWWGroup extends WWGroup {
console.log("Ready to push..."); console.log("Ready to push...");
while (this.#channels[this.#curProcWW].push(rgbFrame) == false) {
console.log("Pushing...");
await sleep(300);
}
if (!this.#channels[this.#curProcWW].isSetPriv(PRIV_FLAGS.EXECUTING)) { if (!this.#channels[this.#curProcWW].isSetPriv(PRIV_FLAGS.EXECUTING)) {
this.#encWorkers[this.#curProcWW].postMessage( this.#encWorkers[this.#curProcWW].postMessage(
makeMsg(MESSAGE_TYPE.DATA, {})) makeMsg(MESSAGE_TYPE.DATA, {}))
} }
while (this.#channels[this.#curProcWW].push(rgbFrame) == false) {
console.log("Pushing...");
await sleep(300);
}
this.#curProcWW = (this.#curProcWW + 1) % this.#numOfEncWorker; this.#curProcWW = (this.#curProcWW + 1) % this.#numOfEncWorker;
} }
......
This diff is collapsed.
...@@ -15,7 +15,7 @@ describe("H264EncWWGroup Spec", () => { ...@@ -15,7 +15,7 @@ describe("H264EncWWGroup Spec", () => {
const RGBAFrameSize = 1920*1080*4; const RGBAFrameSize = 1920*1080*4;
let grp = new H264EncWWGroup("h264enc", { let grp = new H264EncWWGroup("h264enc", {
numOfWW: 8, numOfWW: 11,
encchnlsize: RGBAFrameSize * 10, encchnlsize: RGBAFrameSize * 10,
bridgechnlsize: Math.pow(2, 25) bridgechnlsize: Math.pow(2, 25)
}); });
......
...@@ -18,7 +18,7 @@ FFMPEG_PROTO=${WORKPATH}/src/protos/src ...@@ -18,7 +18,7 @@ FFMPEG_PROTO=${WORKPATH}/src/protos/src
WASM_DIR=${WORKPATH}/src/wasms WASM_DIR=${WORKPATH}/src/wasms
#DEBUG="-O2" #DEBUG="-O2"
DEBUG="-g2 -gseparate-dwarf=./temp.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/temp.debug.wasm" DEBUG="-g2"
BUILD_DIR=${WORKPATH}/Build BUILD_DIR=${WORKPATH}/Build
...@@ -68,24 +68,66 @@ fi ...@@ -68,24 +68,66 @@ fi
OPTIM_FLAGS="$DEBUG --closure 0" OPTIM_FLAGS="$DEBUG --closure 0"
if [[ "$FFMPEG_ST" != "yes" ]]; then if [[ "$FFMPEG_ST" != "yes" ]]; then
EXTRA_FLAGS=( EXTRA_FLAGS_ENCODER=(
-pthread -pthread
-s USE_PTHREADS=1 # enable pthreads support -s USE_PTHREADS=1 # enable pthreads support
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread -s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
-o ${DEMO_PATH}/resources/workers/paraencoder.js -o ${DEMO_PATH}/resources/workers/paraencoder.js
) )
EXTRA_FLAGS_MUXER=(
-pthread
-s USE_PTHREADS=1 # enable pthreads support
-s PROXY_TO_PTHREAD=1 # detach main() from browser/UI main thread
-o ${DEMO_PATH}/resources/workers/paraemuxer.js
)
else else
EXTRA_FLAGS=( EXTRA_FLAGS_ENCODER=(
-o ${DEMO_PATH}/resources/workers/paraencoder.js -o ${DEMO_PATH}/resources/workers/paraencoder.js
) )
EXTRA_FLAGS_MUXER=(
-o ${DEMO_PATH}/resources/workers/paramuxer.js
)
fi fi
FLAGS=( FLAGS_ENCODER=(
-I$BUILD_DIR/include -L$BUILD_DIR/lib -I$LIB_DIR/ffmpeg.wasm-core -I$LIB_DIR/ffmpeg.protos/src
-Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lz
$WASM_DIR/encoder.c
$LIB_DIR/ffmpeg.protos/src/ioctx.cc
$LIB_DIR/ffmpeg.protos/src/utils.cc
$LIB_DIR/ffmpeg.protos/src/proto/movMemProto.cc
$LIB_DIR/ffmpeg.protos/src/proto/proto.cc
-s FORCE_FILESYSTEM=1
-s WASM=1
#-s USE_SDL=0 # 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="createEncoder" # assign export name for browser
-s EXPORTED_FUNCTIONS="[_main,_malloc,_free]" # export main and proxy_main funcs
-s EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory, getValue]" # export preamble funcs
-s INITIAL_MEMORY=268435456 # 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
--pre-js $WORKPATH/pre.js
--post-js $WORKPATH/post.js
-gseparate-dwarf=./encoder.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/encoder.debug.wasm
$OPTIM_FLAGS
${EXTRA_FLAGS_ENCODER[@]}
)
FLAGS_MUXER=(
-I$BUILD_DIR/include -L$BUILD_DIR/lib -I$LIB_DIR/ffmpeg.wasm-core -I$LIB_DIR/ffmpeg.protos/src -I$BUILD_DIR/include -L$BUILD_DIR/lib -I$LIB_DIR/ffmpeg.wasm-core -I$LIB_DIR/ffmpeg.protos/src
-Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments -Wno-deprecated-declarations -Wno-pointer-sign -Wno-implicit-int-float-conversion -Wno-switch -Wno-parentheses -Qunused-arguments
-lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lz -lavdevice -lavfilter -lavformat -lavcodec -lswresample -lswscale -lavutil -lpostproc -lm -lx264 -lz
$WASM_DIR/interfaces.cc $WASM_DIR/muxer.cc
$LIB_DIR/ffmpeg.protos/src/ioctx.cc $LIB_DIR/ffmpeg.protos/src/ioctx.cc
$LIB_DIR/ffmpeg.protos/src/utils.cc $LIB_DIR/ffmpeg.protos/src/utils.cc
$LIB_DIR/ffmpeg.protos/src/proto/movMemProto.cc $LIB_DIR/ffmpeg.protos/src/proto/movMemProto.cc
...@@ -98,18 +140,22 @@ FLAGS=( ...@@ -98,18 +140,22 @@ FLAGS=(
-s INVOKE_RUN=0 # not to run the main() in the beginning -s INVOKE_RUN=0 # not to run the main() in the beginning
-s EXIT_RUNTIME=1 # exit runtime after execution -s EXIT_RUNTIME=1 # exit runtime after execution
-s MODULARIZE=1 # 延迟加载 use modularized version to be more flexible -s MODULARIZE=1 # 延迟加载 use modularized version to be more flexible
-s EXPORT_NAME="createParaEncoder" # assign export name for browser -s EXPORT_NAME="createMuxer" # assign export name for browser
-s EXPORTED_FUNCTIONS="[_main,_malloc,_free]" # export main and proxy_main funcs -s EXPORTED_FUNCTIONS="[_main,_malloc,_free]" # export main and proxy_main funcs
-s EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory, getValue]" # export preamble funcs -s EXPORTED_RUNTIME_METHODS="[FS, cwrap, ccall, setValue, writeAsciiToMemory, getValue]" # export preamble funcs
-s INITIAL_MEMORY=536870912 # 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M -s INITIAL_MEMORY=536870912 # 64 KB * 1024 * 16 * 2047 = 2146435072 bytes ~= 2 GB, 268435456 =256M, 134,217,728 =128M
-s SAFE_HEAP=1
--pre-js $WORKPATH/pre.js --pre-js $WORKPATH/pre.js
--post-js $WORKPATH/post.js --post-js $WORKPATH/post.js
-gseparate-dwarf=./muxer.debug.wasm -s SEPARATE_DWARF_URL=http://localhost:9876/muxer.debug.wasm
$OPTIM_FLAGS $OPTIM_FLAGS
${EXTRA_FLAGS[@]} ${EXTRA_FLAGS_MUXER[@]}
) )
emcc "${FLAGS[@]}"
emcc "${FLAGS_ENCODER[@]}"
emcc "${FLAGS_MUXER[@]}"
chown "$1:$2" ${DEMO_PATH}/resources/workers/paraencoder.js
chown "$1:$2" ${DEMO_PATH}/resources/workers/paraencoder.js chown "$1:$2" ${DEMO_PATH}/resources/workers/paraencoder.js
chown "$1:$2" ${DEMO_PATH}/resources/workers/paraencoder.wasm chown "$1:$2" ${DEMO_PATH}/resources/workers/paramuxer.wasm
chown "$1:$2" ${DEMO_PATH}/resources/workers/paramuxer.wasm
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment