chore: ffmpeg wtf (resolution)

This commit is contained in:
Elysia
2024-07-29 20:13:56 +07:00
parent 55df05d4d8
commit 0bc0246a00
5 changed files with 3 additions and 22 deletions

View File

@@ -48,7 +48,6 @@ client.on('ready', async client => {
const dispatcher = stream.playVideo(input, {
fps: 60,
bitrate: 4000,
resolution: '1080',
});
const dispatcher2 = stream.playAudio(input);
dispatcher.on('start', () => {

View File

@@ -119,22 +119,7 @@ class MediaPlayer extends EventEmitter {
if (!options?.fps) options.fps = 30;
const args = [
'-i',
'-',
'-analyzeduration',
'0',
'-flags',
'low_delay',
'-quality',
'realtime',
'-r',
`${options?.fps}`,
];
if (options?.resolution && options?.resolution !== 'maximum') {
args.push('-vf', `scale=-1:${options.resolution}`);
}
const args = ['-i', '-', '-analyzeduration', '0', '-flags', 'low_delay', '-r', `${options?.fps}`];
if (options?.bitrate && typeof options?.bitrate === 'number') {
args.push('-b:v', `${options?.bitrate}K`);

View File

@@ -79,7 +79,6 @@ class PlayInterface {
* @typedef {Object} VideoOptions
* @property {number} [seek=0] The time to seek to, will be ignored when playing `ogg/opus` or `webm/opus` streams
* @property {number} [fps=30] Video fps
* @property {'maximum' | '480' | '720' | '1080' | '1440'} [resolution='maximum'] Resoluion (Height)
* @property {number} [highWaterMark=12] The maximum number of opus packets to make and store before they are
* actually needed. See https://nodejs.org/en/docs/guides/backpressuring-in-streams/. Setting this value to
* 1 means that changes in volume will be more instant.

View File

@@ -29,7 +29,6 @@ class UnixStream {
if (process.platform === 'win32') {
const pipePrefix = '\\\\.\\pipe\\';
const pipeName = `node-webrtc.${++counter}.sock`;
this.socketPath = path.join(pipePrefix, pipeName);
this.url = this.socketPath;
} else {
@@ -41,7 +40,7 @@ class UnixStream {
fs.statSync(this.socketPath);
fs.unlinkSync(this.socketPath);
} catch (err) {
console.error('UnixStream', err);
// Null
}
const server = net.createServer(onSocket);
@@ -60,4 +59,4 @@ function StreamOutput(stream) {
return new UnixStream(stream, socket => socket.pipe(stream));
}
module.exports = { StreamOutput, StreamInput };
module.exports = { StreamOutput, StreamInput, UnixStream };

1
typings/index.d.ts vendored
View File

@@ -935,7 +935,6 @@ export interface VideoOptions {
presetH26x?: 'ultrafast' | 'superfast' | 'veryfast' | 'faster' | 'fast' | 'medium' | 'slow' | 'slower' | 'veryslow';
inputFFmpegArgs?: string[];
outputFFmpegArgs?: string[];
resolution?: 'maximum' | '480' | '720' | '1080' | '1440';
bitrate?: number | 'auto';
}