Commit 5c4c8fc3 authored by Linshizhi's avatar Linshizhi

update

parent ed7a15b7
......@@ -39,6 +39,11 @@ static List *protos;
static List *ctxs;
static PktBuffer *pktBuffer;
static int framerate = 30;
static int timescale = 90000;
static int duration;
static AVRational tb;
void protoNodeDestr(void *v) {
destroyMMProto((MMProto**)&v);
}
......@@ -49,6 +54,9 @@ void ctxNodeDestr(void *v) {
EM_PORT_API(int) muxInit(int numOfStreams_) {
tb = av_make_q(1, timescale);
duration = timescale / framerate;
numOfStreams = numOfStreams_;
protos = createList();
......@@ -180,6 +188,23 @@ int contextInitializes() {
return OK;
}
void pktTimestampSetup(AVPacket *pkt) {
static int idx = 0;
int pts = idx * duration,
dts = (idx - 1) * duration;
pkt->pts = idx * duration;
pkt->dts = (idx - 1) * duration;
pkt->duration = duration;
pkt->stream_index = 0;
pkt->pos = -1;
printf("PTS: %ld, DTS: %ld\n", pkt->pts, pkt->dts);
++idx;
}
int writeToOFormat() {
int i = inProcContext;
......@@ -199,6 +224,7 @@ int writeToOFormat() {
goto NEXT;
}
pktTimestampSetup(pkt);
streamWriteFrame(octx, pkt);
printf("Writed\n");
......
......@@ -4,25 +4,25 @@ import { sleep, waitCond } from "../src/utils.js";
let paraEnc;
const RGBAFrameSize = 1920*1080*4;
// beforeEach(async () => {
// let trNum = navigator.hardwareConcurrency;
// paraEnc = new ParaEncoder(trNum, {
// codec: "H264",
// config: {
// encchnlsize: RGBAFrameSize * 10,
// bridgechnlsize: Math.pow(2, 25),
// }
// });
// await paraEnc.init();
// }, 20000);
beforeEach(async () => {
let trNum = navigator.hardwareConcurrency;
paraEnc = new ParaEncoder(trNum, {
codec: "H264",
config: {
encchnlsize: RGBAFrameSize * 10,
bridgechnlsize: Math.pow(2, 25),
}
});
await paraEnc.init();
}, 20000);
describe("ParaEncoder", () => {
xit("Encode With ParaEncoder", async () => {
fit("Encode With ParaEncoder", async () => {
const data = new Uint8Array([...Array(RGBAFrameSize).keys()]);
let st = new Date();
for (let i = 0; i < 3000; ++i) {
for (let i = 0; i < 300; ++i) {
await paraEnc.encode(data);
}
......
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