djs-selfbot-v13 3.7.37 → 3.7.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "djs-selfbot-v13",
3
- "version": "3.7.37",
3
+ "version": "3.7.38",
4
4
  "description": "An unofficial discord.js fork for creating selfbots",
5
5
  "main": "./src/index.js",
6
6
  "types": "./typings/index.d.ts",
@@ -104,19 +104,31 @@ class WebRtcStreamSession extends EventEmitter {
104
104
  if (encoder === 'auto') mode = await detectHwEncoder();
105
105
 
106
106
  if (mode === 'nvenc') {
107
- console.log('[stream] encodeur: h264_nvenc');
108
- return Encoders.nvenc({ preset: 'p1' });
107
+ console.log('[stream] encodeur: h264_nvenc (p1 ll)');
108
+ const llOpts = [
109
+ '-preset', 'p1',
110
+ '-tune', 'll',
111
+ '-delay', '0',
112
+ '-rc-lookahead', '0',
113
+ '-no-scenecut', '1',
114
+ '-zerolatency', '1',
115
+ ];
116
+ return () => ({
117
+ H264: { name: 'h264_nvenc', options: llOpts },
118
+ H265: { name: 'hevc_nvenc', options: llOpts },
119
+ AV1: { name: 'av1_nvenc', options: llOpts },
120
+ });
109
121
  }
110
122
  if (mode === 'amf') {
111
- console.log('[stream] encodeur: h264_amf');
123
+ console.log('[stream] encodeur: h264_amf (ultra low latency)');
112
124
  return () => ({
113
125
  H264: {
114
126
  name: 'h264_amf',
115
- options: ['-usage', 'transcoding', '-quality', 'speed'],
127
+ options: ['-usage', 'ultralowlatency', '-quality', 'speed', '-preanalysis', 'false'],
116
128
  },
117
129
  H265: {
118
130
  name: 'hevc_amf',
119
- options: ['-usage', 'transcoding', '-quality', 'speed'],
131
+ options: ['-usage', 'ultralowlatency', '-quality', 'speed', '-preanalysis', 'false'],
120
132
  },
121
133
  });
122
134
  }
@@ -152,25 +164,32 @@ class WebRtcStreamSession extends EventEmitter {
152
164
  };
153
165
  }
154
166
 
155
- const gop = String(fps);
167
+ const gop = String(fps * 2);
168
+ const is720 = Number(height) >= 720;
169
+ const videoBufK = Math.max(Math.round(bitrate * 1.25), is720 ? 3500 : 1200);
156
170
 
157
171
  return {
158
172
  encoder: await this._pickEncoder(),
159
173
  height,
160
- width,
174
+ width: width || (is720 ? 1280 : Math.round((height * 16) / 9 / 2) * 2),
161
175
  frameRate: fps,
162
176
  bitrateVideo: bitrate,
163
- bitrateVideoMax: bitrateMax ?? Math.round(bitrate * 1.5),
177
+ bitrateVideoMax: bitrateMax ?? Math.round(bitrate * 1.3),
164
178
  bitrateAudio: audioBitrate,
165
179
  includeAudio: audio !== false,
166
180
  hardwareAcceleratedDecoding,
167
- minimizeLatency: true,
181
+ minimizeLatency: !is720,
168
182
  customInputOptions: seekSec > 0 ? [`-ss ${String(seekSec)}`] : [],
169
183
  customFfmpegFlags: [
170
184
  '-g', gop,
171
185
  '-keyint_min', gop,
172
186
  '-sc_threshold', '0',
173
187
  '-threads', '0',
188
+ '-bufsize:v', `${videoBufK}k`,
189
+ '-maxrate:v', `${bitrateMax ?? Math.round(bitrate * 1.3)}k`,
190
+ '-force_key_frames', 'expr:gte(t,n_forced*2)',
191
+ '-max_muxing_queue_size', '1024',
192
+ '-flush_packets', '1',
174
193
  ],
175
194
  };
176
195
  }
@@ -230,9 +249,17 @@ class WebRtcStreamSession extends EventEmitter {
230
249
  console.log('[stream] envoi à la résolution/fps natifs de la source (WebRTC)');
231
250
  playOptions = {};
232
251
  } else {
233
- const { height = 720, width = 1280, fps = 60 } = this.options;
234
- console.log(`[stream] envoi ${width}x${height} @ ${fps}fps (WebRTC)`);
235
- playOptions = { width, height, frameRate: fps };
252
+ const { height = 720, width: optWidth, fps = 60, bitrate } = this.options;
253
+ const width = optWidth || (height >= 720 ? 1280 : Math.round((height * 16) / 9 / 2) * 2);
254
+ console.log(
255
+ `[stream] envoi ${width}x${height} @ ${fps}fps, ${bitrate ?? '?'}kbps (WebRTC)`,
256
+ );
257
+ playOptions = {
258
+ width,
259
+ height,
260
+ frameRate: fps,
261
+ readrateInitialBurst: 1,
262
+ };
236
263
  }
237
264
  this.emit('playing');
238
265