Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Transcoder #1

Open
twlite opened this issue Jul 15, 2023 · 0 comments
Open

Add Transcoder #1

twlite opened this issue Jul 15, 2023 · 0 comments
Labels
enhancement New feature or request priority:high

Comments

@twlite
Copy link
Member

twlite commented Jul 15, 2023

Since this library was created for discord-player, the API should be similar to its current transcoder, which is a node.js stream. It works by taking raw stream, piping it to transcoder and receive the desired output.

My current idea is to implement something similar to the following:

import { probeStream, CodecType, Transcoder } from 'mediaplex'

const stream = getInputStream();
const probeResult = await probeStream(stream);

if (!probeResult.result) return; // unsupported stream

const transcoder = new Transcoder({
    format: CodecType.OPUS, // the output format
    sampleRate: 48000, // output sample rate
    channels: 2, // the number of channels
    ... // other options
}); // Transcoder extends Transform stream

const output = stream.pipe(transcoder); // output shall be Opus stream, as specified in format
@twlite twlite added the enhancement New feature or request label Jul 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:high
Projects
None yet
Development

No branches or pull requests

1 participant