restreamer icon indicating copy to clipboard operation
restreamer copied to clipboard

Issue with Capturing RTMP Stream When 'App' is Specified

Open Sadoharu opened this issue 1 year ago • 2 comments

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. 1 2 3 4

I am also attaching photos showing how it looks when the 'App' is not specified. 5 6 7 8

Sadoharu avatar Oct 24 '24 15:10 Sadoharu

This is related to #825 . You can use the datarhei/restreamer:dev image which already includes the fix.

ioppermann avatar Oct 25 '24 09:10 ioppermann

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/ активовано");
})();

Sadoharu avatar Apr 11 '25 09:04 Sadoharu