Streampunk / beamcoder

Node.js native bindings to FFmpeg.
GNU General Public License v3.0
397 stars 76 forks source link

make ogg #40

Open vinnitu opened 4 years ago

vinnitu commented 4 years ago

Hi!

I have opus packets stream. I want to save it to ogg container without reencode. I know original sample rate (16000), channels number (1), frame size (60ms), frames in packet (2) and size in bytes of course(variable length).

My prototype code is

const sampleRate = 16000;
const channels = 1;
const frameSize = 60;
const framesInPacket = 2;

const muxer = beamcoder.muxer({ filename: 'output.ogg' });
const stream = muxer.newStream({ ... }); // how?
Object.assign(stream.coderpar, { ... }); // what?

await muxer.openIO();
await muxer.writeHeader({ ... }); // how?

while (...) {
    const data = Buffer.from([...]); // really got it from network
    const bytes = data.length;

    const frame = beamcoder.frame({ ... }); // how to put data, pts, dts, etc. properly?
    await muxer.writeFrame(frame);
}

await muxer.writeTrailer();

Please help me fill gaps properly.

P.S.: your project is cool