fix(streaming): quote User-Agent header to prevent ffmpeg argument splitting

The ffmpeg -headers option was receiving the User-Agent value split across
multiple arguments due to spaces not being properly quoted. This caused ffmpeg
to interpret "Mozilla/5.0" as an output format, resulting in:
  [NULL @ ...] Unable to find a suitable output format for 'Mozilla/5.0'

Fixed by wrapping the entire headers string in quotes so parseArgsStringToArgv
treats it as a single argument. The headers string is now properly passed to
ffmpeg as: -headers "User-Agent: ... \r\nConnection: ..."

The fix has been applied to vendor/discord-video-stream/src/media/newApi.ts
and compiled into dist/media/newApi.js. A patch file and documentation have
been added to the patches/ directory for reference.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
MythEclipse
2026-05-23 17:35:42 +07:00
co-authored by Claude Opus 4.7
parent f2b476e1f0
commit 9b49c05f32
2 changed files with 54 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# Patches
This directory contains patches for vendor dependencies that have local modifications.
## ffmpeg-headers-fix.patch
**Issue:** Screen share streaming fails with ffmpeg error:
```
[NULL @ ...] Unable to find a suitable output format for 'Mozilla/5.0'
```
**Root Cause:** The `@dank074/discord-video-stream` library's `prepareStream` function passes HTTP headers to ffmpeg without proper quoting. The `fluent-ffmpeg-simplified` library uses `parseArgsStringToArgv` to parse command-line arguments, which splits strings by spaces. This causes the User-Agent header value (with spaces) to be split into multiple separate arguments instead of being kept as a single value.
**Fix:** Wrap the entire headers string in quotes so `parseArgsStringToArgv` treats it as a single argument:
```typescript
// Before (broken)
command.inputOptions(
"-headers",
Object.entries(customHeaders)
.map(([k, v]) => `${k}: ${v}`)
.join("\r\n"),
);
// After (fixed)
const headersString = Object.entries(customHeaders)
.map(([k, v]) => `${k}: ${v}`)
.join("\r\n");
command.inputOptions(`-headers "${headersString}"`);
```
**Applied To:** `vendor/discord-video-stream/src/media/newApi.ts` (lines 263-269)
**Status:** Patch is applied locally. The compiled output in `dist/media/newApi.js` reflects this fix.
**Note:** This is a local patch to the vendor submodule. To make this permanent, it should be submitted as a PR to the upstream repository: https://github.com/dank074/discord-video-stream
+19
View File
@@ -0,0 +1,19 @@
diff --git a/src/media/newApi.ts b/src/media/newApi.ts
index original..modified 100644
--- a/src/media/newApi.ts
+++ b/src/media/newApi.ts
@@ -261,12 +261,10 @@ export function prepareStream(
if (isHttpUrl) {
- command.inputOptions(
- "-headers",
- Object.entries(customHeaders)
- .map(([k, v]) => `${k}: ${v}`)
- .join("\r\n"),
- );
+ const headersString = Object.entries(customHeaders)
+ .map(([k, v]) => `${k}: ${v}`)
+ .join("\r\n");
+ command.inputOptions(`-headers "${headersString}"`);
if (!isHls) {
command.inputOptions([
"-reconnect 1",