ossrs / srs

SRS is a simple, high-efficiency, real-time video server supporting RTMP, WebRTC, HLS, HTTP-FLV, SRT, MPEG-DASH, and GB28181.
https://ossrs.io
MIT License
24.74k stars 5.28k forks source link

Convert SRT to RTMP #3952

Closed streamingsystems closed 4 months ago

streamingsystems commented 4 months ago

Hi,

I see in your documents "Q&A" you have this:

Does SRS support forwarding SRT streams to Nginx?

Yes, it is supported. You can use OBS/FFmpeg to push SRT streams to SRS, and SRS will convert the SRT stream into the RTMP protocol. Then, you can convert RTMP to HLS, FLV, WebRTC, and also forward the RTMP stream to Nginx.

--

I would like to do exactly this but am unclear on how to setup the conf file to combine SRT and Forward in a single conf file.

I would like SRT to come in, and then make a call to my API to "dynamic forward" the RTMP to my nginx server. Very important I would like the SRT "stream_id" to come into the http api forward request as I will use the stream id to determine what RTMP URL I set in the response. In other words, the RTMP url I determine will be conditional based on the stream_id coming into the SRT so I need to know the stream_id in my API code.

If someone would kindly see if what I am doing is correct I would greatly appreciate it.

Here is my conf:

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;

srt_server {
    enabled on;
    listen 10080;
    maxbw 1000000000;
    connect_timeout 4000;
    peerlatency 0;
    recvlatency 0;
    latency 0;
    tsbpdmode off;
    tlpktdrop off;
    sendbuf 2000000;
    recvbuf 2000000;
    default_app live;
}

vhost __defaultVhost__ {

    srt {
        enabled     on;
        srt_to_rtmp on;
    }

    forward {
        enabled on;
        backend http://127.0.0.1:80/api/v1/forward; # this will return the "forwards" based on the stream_id for SRT
    }

}

Or, because the SRT default_app is "live" do I need the conf file to be this:

listen              1935;
max_connections     1000;
daemon              off;
srs_log_tank        console;

srt_server {
    enabled on;
    listen 10080;
    maxbw 1000000000;
    connect_timeout 4000;
    peerlatency 0;
    recvlatency 0;
    latency 0;
    tsbpdmode off;
    tlpktdrop off;
    sendbuf 2000000;
    recvbuf 2000000;
    default_app live;
}

#this handles SRT and forwards to RTMP?
vhost __defaultVhost__ {

    srt {
        enabled     on;
        srt_to_rtmp on;
    }

}

#this makes a call to my API which returns the forward urls
vhost live {

    forward {
        enabled on;
        backend http://127.0.0.1:80/api/v1/forward; # this will return the "forwards" based on the stream_id for SRT
    }

}
streamingsystems commented 4 months ago

When I send RTMP direct my forward works perfectly, but when I send SRT with just a stream_id, for some reason the forward is not being triggered (my API is not even being called to get the RTMP forwards).

streamingsystems commented 4 months ago

solved

winlinvip commented 4 months ago

How did you address it? @streamingsystems

streamingsystems commented 4 months ago

I was forgetting to put the #!:: information in with the stream id, so I presume it was not calling the SRT to RTMP. Once I added that it started working.

From: Winlin @.> Date: Monday, February 12, 2024 at 6:42 PM To: ossrs/srs @.> Cc: streamingsystems @.>, Mention @.> Subject: Re: [ossrs/srs] Convert SRT to RTMP (Issue #3952)

How did you address it? @streamingsystemshttps://github.com/streamingsystems

— Reply to this email directly, view it on GitHubhttps://github.com/ossrs/srs/issues/3952#issuecomment-1939904944, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AOI5PRIOTNRGASW5XHO2VFDYTKZFVAVCNFSM6AAAAABDERJ4K6VHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMZZHEYDIOJUGQ. You are receiving this because you were mentioned.Message ID: @.***>