restreamer
restreamer copied to clipboard
Issue with Capturing RTMP Stream When 'App' is Specified
There is an issue when adding an incoming RTMP stream that is already being streamed to the server. If the 'App' is specified, it cannot be captured. Without specifying the 'App', it is captured correctly.
I am attaching photos showing how it looks when the 'App' is specified.
I am also attaching photos showing how it looks when the 'App' is not specified.
This is related to #825 . You can use the datarhei/restreamer:dev image which already includes the fix.
Monkey-patch to fix if app=live
(function() {
const originalFetch = window.fetch;
window.fetch = async (input, init) => {
if (
typeof init?.body === "string" &&
init.body.includes("{rtmp,name=")
) {
const parsed = JSON.parse(init.body);
if (parsed?.input?.[0]?.address?.startsWith("{rtmp,name=")) {
const oldAddress = parsed.input[0].address;
const fixedAddress = oldAddress.replace("{rtmp,name=/live/", "{rtmp,name=").replace("{rtmp,name=//live/", "{rtmp,name=");
parsed.input[0].address = fixedAddress;
const newBody = JSON.stringify(parsed);
console.log("🛠 Виправлено input.address:");
console.log("📤 Було:", oldAddress);
console.log("✅ Стало:", fixedAddress);
init.body = newBody;
}
}
return originalFetch(input, init);
};
console.log("✅ fetch monkey-patch для address=name=... без /live/ активовано");
})();