chore: ffmpeg wtf (resolution)
This commit is contained in:
@@ -48,7 +48,6 @@ client.on('ready', async client => {
|
|||||||
const dispatcher = stream.playVideo(input, {
|
const dispatcher = stream.playVideo(input, {
|
||||||
fps: 60,
|
fps: 60,
|
||||||
bitrate: 4000,
|
bitrate: 4000,
|
||||||
resolution: '1080',
|
|
||||||
});
|
});
|
||||||
const dispatcher2 = stream.playAudio(input);
|
const dispatcher2 = stream.playAudio(input);
|
||||||
dispatcher.on('start', () => {
|
dispatcher.on('start', () => {
|
||||||
|
|||||||
@@ -119,22 +119,7 @@ class MediaPlayer extends EventEmitter {
|
|||||||
|
|
||||||
if (!options?.fps) options.fps = 30;
|
if (!options?.fps) options.fps = 30;
|
||||||
|
|
||||||
const args = [
|
const args = ['-i', '-', '-analyzeduration', '0', '-flags', 'low_delay', '-r', `${options?.fps}`];
|
||||||
'-i',
|
|
||||||
'-',
|
|
||||||
'-analyzeduration',
|
|
||||||
'0',
|
|
||||||
'-flags',
|
|
||||||
'low_delay',
|
|
||||||
'-quality',
|
|
||||||
'realtime',
|
|
||||||
'-r',
|
|
||||||
`${options?.fps}`,
|
|
||||||
];
|
|
||||||
|
|
||||||
if (options?.resolution && options?.resolution !== 'maximum') {
|
|
||||||
args.push('-vf', `scale=-1:${options.resolution}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (options?.bitrate && typeof options?.bitrate === 'number') {
|
if (options?.bitrate && typeof options?.bitrate === 'number') {
|
||||||
args.push('-b:v', `${options?.bitrate}K`);
|
args.push('-b:v', `${options?.bitrate}K`);
|
||||||
|
|||||||
@@ -79,7 +79,6 @@ class PlayInterface {
|
|||||||
* @typedef {Object} VideoOptions
|
* @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} [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 {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
|
* @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
|
* 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.
|
* 1 means that changes in volume will be more instant.
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ class UnixStream {
|
|||||||
if (process.platform === 'win32') {
|
if (process.platform === 'win32') {
|
||||||
const pipePrefix = '\\\\.\\pipe\\';
|
const pipePrefix = '\\\\.\\pipe\\';
|
||||||
const pipeName = `node-webrtc.${++counter}.sock`;
|
const pipeName = `node-webrtc.${++counter}.sock`;
|
||||||
|
|
||||||
this.socketPath = path.join(pipePrefix, pipeName);
|
this.socketPath = path.join(pipePrefix, pipeName);
|
||||||
this.url = this.socketPath;
|
this.url = this.socketPath;
|
||||||
} else {
|
} else {
|
||||||
@@ -41,7 +40,7 @@ class UnixStream {
|
|||||||
fs.statSync(this.socketPath);
|
fs.statSync(this.socketPath);
|
||||||
fs.unlinkSync(this.socketPath);
|
fs.unlinkSync(this.socketPath);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('UnixStream', err);
|
// Null
|
||||||
}
|
}
|
||||||
|
|
||||||
const server = net.createServer(onSocket);
|
const server = net.createServer(onSocket);
|
||||||
@@ -60,4 +59,4 @@ function StreamOutput(stream) {
|
|||||||
return new UnixStream(stream, socket => socket.pipe(stream));
|
return new UnixStream(stream, socket => socket.pipe(stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
module.exports = { StreamOutput, StreamInput };
|
module.exports = { StreamOutput, StreamInput, UnixStream };
|
||||||
|
|||||||
1
typings/index.d.ts
vendored
1
typings/index.d.ts
vendored
@@ -935,7 +935,6 @@ export interface VideoOptions {
|
|||||||
presetH26x?: 'ultrafast' | 'superfast' | 'veryfast' | 'faster' | 'fast' | 'medium' | 'slow' | 'slower' | 'veryslow';
|
presetH26x?: 'ultrafast' | 'superfast' | 'veryfast' | 'faster' | 'fast' | 'medium' | 'slow' | 'slower' | 'veryslow';
|
||||||
inputFFmpegArgs?: string[];
|
inputFFmpegArgs?: string[];
|
||||||
outputFFmpegArgs?: string[];
|
outputFFmpegArgs?: string[];
|
||||||
resolution?: 'maximum' | '480' | '720' | '1080' | '1440';
|
|
||||||
bitrate?: number | 'auto';
|
bitrate?: number | 'auto';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user