Commit e476a00e authored by Linshizhi's avatar Linshizhi

Add framerate parameter to muxer.

parent 8b1268bf
...@@ -100,8 +100,6 @@ async function init(msg) { ...@@ -100,8 +100,6 @@ async function init(msg) {
height_ = info.height; height_ = info.height;
frameRate_ = info.fps; frameRate_ = info.fps;
RGBFrameSize = width_ * height_ * 4; RGBFrameSize = width_ * height_ * 4;
console.log(width_, height_, frameRate_);
} }
// Wait encoder init // Wait encoder init
......
// Muxer Parameters
let fps = 30;
// Status // Status
let ident = undefined; let ident = undefined;
let isInited = false; let isInited = false;
...@@ -74,9 +77,11 @@ async function init(msg) { ...@@ -74,9 +77,11 @@ async function init(msg) {
MUX_BUFFER_SIZE = info.wasmBufSize; MUX_BUFFER_SIZE = info.wasmBufSize;
if ('numOfEncs' in info) if ('numOfEncs' in info)
numOfEncs = info.numOfEncs; numOfEncs = info.numOfEncs;
if ('fps' in info)
fps = info.fps;
/* Init Muxer */ /* Init Muxer */
muxer._muxInit(numOfEncs); muxer._muxInit(numOfEncs, fps);
eof = [...Array(numOfEncs).keys()].map(() => false); eof = [...Array(numOfEncs).keys()].map(() => false);
postMessage(makeMsg(MESSAGE_TYPE.INIT, {})); postMessage(makeMsg(MESSAGE_TYPE.INIT, {}));
......
...@@ -119,7 +119,7 @@ export class H264EncWWGroup extends WWGroup { ...@@ -119,7 +119,7 @@ export class H264EncWWGroup extends WWGroup {
await this.#muxWorker.start(async ww => { await this.#muxWorker.start(async ww => {
return await initStrategies(muxInit, INIT_FLAGS.NONE, ww, return await initStrategies(muxInit, INIT_FLAGS.NONE, ww,
// muxInit parameters // muxInit parameters
this.#numOfEncWorker, Math.pow(2, 22), ww) this.#numOfEncWorker, Math.pow(2, 22), ww, this.#fps)
}); });
for (let i = 0; i < this.#numOfEncWorker; ++i) { for (let i = 0; i < this.#numOfEncWorker; ++i) {
...@@ -311,9 +311,9 @@ async function encInit(chnls, size, ww, blockSize, width, height, fps) { ...@@ -311,9 +311,9 @@ async function encInit(chnls, size, ww, blockSize, width, height, fps) {
return true; return true;
} }
async function muxInit(numOfEncs, size, ww) { async function muxInit(numOfEncs, size, ww, fps_) {
ww.postMessage( ww.postMessage(
makeMsg(MESSAGE_TYPE.INIT, { wasmBufSize: size, numOfEncs: numOfEncs })); makeMsg(MESSAGE_TYPE.INIT, { wasmBufSize: size, numOfEncs: numOfEncs, fps: fps_ }));
} }
async function encMuxBridge(bridge, size, enc, mux) { async function encMuxBridge(bridge, size, enc, mux) {
......
...@@ -52,8 +52,9 @@ void ctxNodeDestr(void *v) { ...@@ -52,8 +52,9 @@ void ctxNodeDestr(void *v) {
} }
EM_PORT_API(int) muxInit(int numOfStreams_) { EM_PORT_API(int) muxInit(int numOfStreams_, int framerate_) {
framerate = framerate_;
tb = av_make_q(1, timescale); tb = av_make_q(1, timescale);
duration = timescale / framerate; duration = timescale / framerate;
......
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