Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SRT stream not available via HTTP-FLV #4242

Closed
pannal opened this issue Nov 21, 2024 · 15 comments
Closed

SRT stream not available via HTTP-FLV #4242

pannal opened this issue Nov 21, 2024 · 15 comments
Labels
EnglishNative This issue is conveyed exclusively in English.

Comments

@pannal
Copy link

pannal commented Nov 21, 2024

Describe the bug
I'm pushing a h264 stream using OBS to SRS's SRT endpoint. From how I understand the documentation, this should then be exposed via /app/live/key.flv, but it's unplayable (timeout via mpegts.js and VLC). Am I missing something?

SRS is behind an NGINX reverse proxy if that helps, config:

    location / {
        include snippets/authelia/authrequest.conf;
        include snippets/proxy.conf;
        proxy_pass http://127.0.0.1:18080/$request_uri;
    }


    # For SRS homepage, console and players
    #   http://r.ossrs.net/console/
    #   http://r.ossrs.net/players/
    location ~ ^/(console|players)/ {
        include snippets/authelia/authrequest.conf;
        include snippets/proxy.conf;
        proxy_pass http://127.0.0.1:18080/$request_uri;
    }
    # For SRS streaming, for example:
    #   http://r.ossrs.net/live/livestream.flv
    #   http://r.ossrs.net/live/livestream.m3u8
    location ~ ^/.+/.*\.(flv|m3u8|ts|aac|mp3)$ {
        #include snippets/authelia/authrequest.conf;
        #include snippets/proxy.conf;
        proxy_pass http://127.0.0.1:18080$request_uri;
    }
    # For SRS backend API for console.
    # For SRS WebRTC publish/play API.
    location ~ ^/(api|rtc)/ {
        proxy_pass http://127.0.0.1:1985$request_uri;
    }

SRS config:

# docker config for srs.
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
# For docker, please use docker logs to manage the logs of SRS.
# See https://docs.docker.com/config/containers/logging/
srs_log_tank        console;
daemon              off;
http_api {
    enabled         on;
    listen          1985;
}
http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}
rtc_server {
    enabled off;
    listen 8000;
    # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#config-candidate
    candidate $CANDIDATE;
}
#srt_server {
#    enabled on;
#    listen 10080;
#    connect_timeout 4000;
#    peerlatency 300; # RTT * 3
#    recvlatency 300; # RTT * 3
#    latency 300; # RTT * 3
#    tlpktdrop on;
#    tsbpdmode on;
#}
srt_server {
    enabled on;
    listen 10080;
    connect_timeout 4000;
    peerlatency 0;
    recvlatency 0;
    latency 0;
    tlpktdrop off;
    tsbpdmode off;
}
vhost __defaultVhost__ {
    hls {
        enabled         on;
    }
    srt {
        enabled     on;
        srt_to_rtmp on;
    }
    http_remux {
        enabled     on;
        mount       /[app]/[stream].flv;
    }
    rtc {
        enabled     off;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtmp-to-rtc
        rtmp_to_rtc off;
        # @see https://ossrs.net/lts/zh-cn/docs/v4/doc/webrtc#rtc-to-rtmp
        rtc_to_rtmp off;
    }
}

Docker-Compose:

srs:
    container_name: srs
    image: ossrs/srs:v6
    volumes:
      - /etc/srs/docker.conf:/usr/local/srs/conf/docker.conf
    ports:
      - 1339:1935/tcp
      - 127.0.0.1:1985:1985
      - 127.0.0.1:18080:8080
      - 8000:8000/udp
      - 10080:10080/udp

Version
SRS V6 docker (via dockerhub), SRS/6.0.155

@winlinvip winlinvip added the EnglishNative This issue is conveyed exclusively in English. label Nov 21, 2024
@suzp1984
Copy link
Contributor

The nginx config its proxy:

location ~ ^/.+/.*\.(flv|m3u8|ts|aac|mp3)$ {
        #include snippets/authelia/authrequest.conf;
        #include snippets/proxy.conf;
        proxy_pass http://127.0.0.1:18080$request_uri;
    }

proxy to 127.0.0.0:18080, but srs config its http server listen on 8080:

http_server {
    enabled         on;
    listen          8080;
    dir             ./objs/nginx/html;
}

@pannal
Copy link
Author

pannal commented Nov 22, 2024

Yes, the port is remapped in docker to expose on 18080 because the port is already in use on the host machine from another service.

To be clear: this Config works when directly streaming to RTMP and using the .flv URL in VLC or mpegts.js.

Only when publishing using SRT the flv is not available/doesn't load (times out).

@pannal
Copy link
Author

pannal commented Nov 22, 2024

Can I get you some logs? Any debug settings I need?

Edit: Updated the first post with the docker config and specific version of SRS 6.

@suzp1984
Copy link
Contributor

  • 127.0.0.1:18080:8080

Is the http://127.0.0.1:18080/live/livestream.flv plays well in your localhost?

@pannal
Copy link
Author

pannal commented Nov 27, 2024

It plays well using RTMP and playing via the external https://domain/live/livestream.flv, yes (via the NGINX location, which uses http://127.0.0.1:18080/live/livestream.flv).

But not for SRT.

@suzp1984
Copy link
Contributor

I tried your srs conf, SRT publish and http-flv plays well in my machine.

ffmpeg -re -i source.flv -c copy -f mpegts 'srt://localhost:10080?streamid=#!::r=live/livestream,m=publish'
ffplay http://localhost:8080/live/livestream.flv

Try above two cmds, check in your env.

@pannal
Copy link
Author

pannal commented Nov 27, 2024

Does ffplay http://localhost:18080/live/livestream.flv work as well? Because that's the port used for exposing the streams.

@pannal
Copy link
Author

pannal commented Dec 3, 2024

@suzp1984 You're right, I must've been doing something wrong.

When trying to play back an SRT HEVC stream, it still works with mpegts.js, but ffplay shows:

[flv @ 000001c756560600] Video codec (c) is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[flv @ 000001c756560600] If you want to help, upload a sample of this file to https://streams.videolan.org/upload/ and contact the ffmpeg-devel mailing list. ([email protected])
[flv @ 000001c756560600] Video codec (c) is not implemented. Update your FFmpeg version to the newest one from Git. If the problem still occurs, it means that your file has a feature which has not been implemented.
[flv @ 000001c756560600] If you want to help, upload a sample of this file to https://streams.videolan.org/upload/ and contact the ffmpeg-devel mailing list. ([email protected])

How would I push an AV1 stream via SRT, to get it inside stream.flv to be played back with mpegts.js? That wouldn't work via srt_to_rtmp I guess, but would need a remux? (AV1 is possible inside mpegts.js in the development version AFAIK)

The doc states:

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.

Why the intermediate step to RTMP? That severely limits the video codecs one can use.

@suzp1984
Copy link
Contributor

suzp1984 commented Dec 3, 2024

That's What the SRS name initially short for? SRS == Simple RTMP Server.

@pannal
Copy link
Author

pannal commented Dec 3, 2024

If that's the answer to any feature requests, that'd be sad.

No, honestly: Would it be possible to not have that intermediate step to RTMP? Or, ideally, support the latest ERTMP spec out of the box? Thank you!

@suzp1984
Copy link
Contributor

suzp1984 commented Dec 4, 2024

SRS support Enhanced RTMP, but only HEVC(H.265) code.

@pannal
Copy link
Author

pannal commented Dec 4, 2024

Yes, that's why I was referring to the latest ERTMP spec, which is Enhanced RTMP V2: https://veovera.org/docs/enhanced/enhanced-rtmp-v2.html

@zapf2000
Copy link

zapf2000 commented Dec 4, 2024

As far as i know, AV1 is not yet supported with SRT (only WebRTC and eRTMP), because SRT uses MPEG-TS and AV1 is not yet implemented for transport stream usage.

@pannal
Copy link
Author

pannal commented Dec 4, 2024

SRT is codec agnostic by nature, but relies on MPEGTS, correct; Nimble for example accepts AV1 via SRT already; the other current MPEGTS implementations don't (FFmpeg at least doesn't); Not sure if the spec is even finalized yet: https://github.com/AOMediaCodec/av1-mpeg2-ts/issues/

So the only option at the moment would be to implement the Enhanced RTMP V2 spec

@pannal
Copy link
Author

pannal commented Dec 4, 2024

But the original issue has been resolved, so let's continue here: #4239

@pannal pannal closed this as completed Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
EnglishNative This issue is conveyed exclusively in English.
Projects
None yet
Development

No branches or pull requests

4 participants