bluenviron / mediamtx

Ready-to-use SRT / WebRTC / RTSP / RTMP / LL-HLS media server and media proxy that allows to read, publish, proxy, record and playback video and audio streams.
MIT License
10.71k stars 1.4k forks source link

runOnReady disconnects the client when I`m trying to publish to RTMP #3514

Open Pepslee opened 4 days ago

Pepslee commented 4 days ago

Which version are you using?

v1.8.3

Which operating system are you using?

Describe the issue

runOnReady disconnects the client when I`m trying to publish to RTMP

Describe how to replicate the issue

I have run two mediamtx, one (localhost) is for pulling stream from some RTSP source , another is where I want to restream RTMP (10.10.10.3). I open the browser and connect to local mediamtx http://0.0.0.0:8889/test1/ and I see the video. When I try to add runOnReady to restream into RTMP server (10.10.10.3), local mediamtx disconnects my client http://0.0.0.0:8889/test1/ for couple of seconds and just after it connects again and starts publishing to RTMP.

But when I don't use runOnReady and manually run the command

gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8555/test1 ! rtph264depay ! h264parse ! flvmux ! rtmpsink location="rtmp://10.10.10.3:1935/test" max-lateness=0 sync=false

it doesn't disconnect me and every think work fine and gst-launch publishes to RTMP port of mediamtx 10.10.10.3

import asyncio

import httpx

class MediamtxApi:
    def __init__(self, client: httpx.AsyncClient):
        self.client = client

    async def add_path(self, input_path: str, name: str):
        body = {"name": name, "source": input_path, "sourceOnDemand": True, "overridePublisher": False}
        await self.client.post(url=f'config/paths/add/{name}', json=body)

    async def enable_rtmp(self, name, url):
        body = {
            "runOnReady": f'gst-launch-1.0 rtspsrc location=rtsp://127.0.0.1:8555/test1 ! rtph264depay ! h264parse ! flvmux ! rtmpsink location="{url}" max-lateness={0} sync=false',
        }
        await self.client.patch(url=f'config/paths/patch/{name}', json=body)

async def main():
    api = MediamtxApi(client=httpx.AsyncClient(base_url='http://localhost:9997/v3'))

    await api.add_path(input_path='whep://10.10.10.2:8889/lores/whep', name='test1')
    await asyncio.sleep(10)
    await api.enable_rtmp(url='rtmp://10.10.10.3:1935/test1', name='test1')

if __name__ == '__main__':
    asyncio.run(main())

Did you attach the server logs?

yes mediamtx_runOnRead_log.txt run on ready command is presented in python code mediamtx_log_manual_command.txt manual command is presented in description

Did you attach a network dump?

no