piixishstream 1.0.5 → 1.0.7

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.
@@ -33,6 +33,7 @@ export function prepareStream(input, options = {}, cancelSignal) {
33
33
  },
34
34
  customInputOptions: [],
35
35
  customFfmpegFlags: [],
36
+ audioInput: undefined,
36
37
  };
37
38
  function mergeOptions(opts) {
38
39
  return {
@@ -67,6 +68,7 @@ export function prepareStream(input, options = {}, cancelSignal) {
67
68
  },
68
69
  customInputOptions: opts.customInputOptions ?? defaultOptions.customInputOptions,
69
70
  customFfmpegFlags: opts.customFfmpegFlags ?? defaultOptions.customFfmpegFlags,
71
+ audioInput: opts.audioInput ?? defaultOptions.audioInput,
70
72
  };
71
73
  }
72
74
  const mergedOptions = mergeOptions(options);
@@ -80,8 +82,11 @@ export function prepareStream(input, options = {}, cancelSignal) {
80
82
  }
81
83
  const output = new PassThrough();
82
84
  // command creation
83
- const command = ffmpeg(input);
84
- // input options
85
+ const command = ffmpeg(input);
86
+ if (mergedOptions.audioInput) {
87
+ command.input(mergedOptions.audioInput).inputOptions(["-stream_loop", "-1"]);
88
+ }
89
+ // input options
85
90
  if (mergedOptions.customInputOptions &&
86
91
  mergedOptions.customInputOptions.length > 0) {
87
92
  command.inputOptions(mergedOptions.customInputOptions);
@@ -144,10 +149,14 @@ export function prepareStream(input, options = {}, cancelSignal) {
144
149
  .outputOptions(encoderSettings.globalOptions ?? []);
145
150
  }
146
151
  // audio setup
147
- const { includeAudio, bitrateAudio } = mergedOptions;
148
- if (includeAudio)
152
+ const { includeAudio, bitrateAudio, audioInput } = mergedOptions;
153
+ if (includeAudio) {
154
+ if (audioInput) {
155
+ command.addOutputOption("-map 1:a");
156
+ } else {
157
+ command.addOutputOption("-map 0:a:0?");
158
+ }
149
159
  command
150
- .addOutputOption("-map 0:a:0?")
151
160
  .audioChannels(2)
152
161
  /*
153
162
  * I don't have much surround sound material to test this with,
@@ -159,6 +168,7 @@ export function prepareStream(input, options = {}, cancelSignal) {
159
168
  .audioCodec("libopus")
160
169
  .audioBitrate(`${bitrateAudio}k`)
161
170
  .audioFilters("volume@internal_lib=1.0");
171
+ }
162
172
  // Add custom ffmpeg flags
163
173
  if (mergedOptions.customFfmpegFlags &&
164
174
  mergedOptions.customFfmpegFlags.length > 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "piixishstream",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "description": "Experiment for making video streaming work for discord selfbots",
5
5
  "main": "./dist/index.js",
6
6
  "exports": "./dist/index.js",
@@ -82,3 +82,5 @@
82
82
  }
83
83
  }
84
84
 
85
+
86
+
@@ -137,7 +137,8 @@ export function prepareStream(
137
137
  Connection: "keep-alive",
138
138
  },
139
139
  customInputOptions: [],
140
- customFfmpegFlags: [],
140
+ customFfmpegFlags: [],
141
+ audioInput: undefined,
141
142
  } satisfies PrepareStreamOptions;
142
143
 
143
144
  function mergeOptions(opts: Partial<PrepareStreamOptions>) {
@@ -211,7 +212,12 @@ export function prepareStream(
211
212
 
212
213
  // command creation
213
214
  const command = ffmpeg(input);
214
-
215
+ if (mergedOptions.audioInput) {
216
+ command.input(mergedOptions.audioInput).inputOptions(["-stream_loop", "-1"]);
217
+ }
218
+ if (mergedOptions.audioInput) {
219
+ command.input(mergedOptions.audioInput).inputOptions(["-stream_loop", "-1"]);
220
+ }
215
221
  // input options
216
222
  if (
217
223
  mergedOptions.customInputOptions &&
@@ -298,10 +304,10 @@ export function prepareStream(
298
304
  }
299
305
 
300
306
  // audio setup
301
- const { includeAudio, bitrateAudio } = mergedOptions;
307
+ const { includeAudio, bitrateAudio, audioInput } = mergedOptions;
302
308
  if (includeAudio)
303
309
  command
304
- .addOutputOption("-map 0:a:0?")
310
+ .addOutputOption(mergedOptions.audioInput ? "-map 1:a" : "-map 0:a:0?")
305
311
  .audioChannels(2)
306
312
  /*
307
313
  * I don't have much surround sound material to test this with,
@@ -617,8 +623,10 @@ export async function playStream(
617
623
  return new Promise<void>((resolve, reject) => {
618
624
  cleanupFuncs.push(() => {
619
625
  stopStream();
620
- conn.mediaConnection.setSpeaking(false);
621
- conn.mediaConnection.setVideoAttributes(false);
626
+ if (!mergedOptions.keepConnection) {
627
+ conn.mediaConnection.setSpeaking(false);
628
+ conn.mediaConnection.setVideoAttributes(false);
629
+ }
622
630
  });
623
631
  let cleanedUp = false;
624
632
  const cleanup = () => {