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

srs distribution of webrtc failed, the stream cannot be played #1727

Closed
luozhijunc opened this issue Apr 27, 2020 · 14 comments
Closed

srs distribution of webrtc failed, the stream cannot be played #1727

luozhijunc opened this issue Apr 27, 2020 · 14 comments
Assignees
Labels
TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Milestone

Comments

@luozhijunc
Copy link

luozhijunc commented Apr 27, 2020

Description
Configure SRS4 to pull RTSP stream (ingest RTSP) into SRS. SRS fails to distribute the stream via WebRTC, and WebRTC is unable to play the stream (it can be played using the RTMP protocol).

Description
Please describe the issue you are facing.

1. SRS Version: 4.0.23
2. SRS Configuration:
Based on the conf/rtc.conf file, add the following configuration for pulling streams:

vhost __defaultVhost__ {
    rtc {
        enabled     on;
        bframe      discard;
    }
	ingest livestream {
        enabled      on;
        input {
                type    stream;
                url     rtsp://admin:admin@192.168.1.108:554/cam/realmonitor?channel=1&subtype=1&unicast=true&proto=Onvif;
        }
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine {
                enabled          off;
                output          rtmp://192.168.1.206/live/stream;
        }
	}

}

Replay

1. Start SRS
2. Play webrtc://192.168.1.206/live/stream.
3. Unable to play WebRTC, but able to play RTMP.

Expected Behavior

Able to view streams through WebRTC

TRANS_BY_GPT3

@luozhijunc luozhijunc changed the title srs分发来着webrtc失败,流无法播放 srs分发webrtc失败,流无法播放 Apr 27, 2020
@IIPoliII
Copy link

^^^ I think it's the same as my issue

@dean-river
Copy link

dean-river commented Apr 28, 2020

Try adding merge_nalus off; to the RTC configuration and see if it can play. It may be the same as mine.

TRANS_BY_GPT3

@IIPoliII
Copy link

IIPoliII commented Apr 28, 2020

@dean-river like that?

listen              1935;
max_connections     1000;
srs_log_tank        console;
srs_log_file        ./objs/srs.log;
daemon              off;

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

http_api {
    enabled         on;
    listen          1985;
}
stats {
    network         0;
}
rtc_server {
    enabled         on;
    # Listen at udp://8000
    listen          8000;
    #
    # The $CANDIDATE means fetch from env, if not configed, use * as default.
    #
    # The * means retrieving server IP automatically, from all network interfaces,
    # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
    candidate       $CANDIDATE;
    merge_nalus off;
}

vhost __defaultVhost__ {
    rtc {
        enabled     on;
        bframe      discard;
    }
}


because i still get the error :

[2020-04-28 01:53:19.821][Warn][11556][509][11] RTC error code=5020 : create session : stream /live/test busy
thread [11556][509]: do_serve_http() [src/app/srs_app_http_api.cpp:924][errno=11]
thread [11556][509]: create_rtc_session() [src/app/srs_app_rtc_conn.cpp:3176][errno=11]
[2020-04-28 01:53:19.918][Warn][11556][509][104] client disconnect peer. ret=1007

@dean-river
Copy link

dean-river commented Apr 28, 2020

Oh, you and mine are different. Mine doesn't have any error logs, but yours is throwing an error during the interactive SDP phase.

TRANS_BY_GPT3

@luozhijunc
Copy link
Author

luozhijunc commented Apr 30, 2020

After adding "merge_nalus off;", we can play using WebRTC on this side.
Based on the configuration in "conf/rtc.conf".

rtc_server {
    enabled         on;
    # Listen at udp://8000
    listen          8000;
    #
    # The $CANDIDATE means fetch from env, if not configed, use * as default.
    #
    # The * means retrieving server IP automatically, from all network interfaces,
    # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
    candidate       $CANDIDATE;
    merge_nalus off;
}

vhost __defaultVhost__ {
    rtc {
        enabled     on;
        bframe      discard;
    }
    ingest livestream {
        enabled      on;
        input {
                type    stream;
                url     rtsp://192.168.1.88/av0_0;
        }
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine {
                enabled          off;
                output          rtmp://192.168.1.206/live/stream;
        }
    }
}

TRANS_BY_GPT3

@wnpllrzodiac
Copy link
Contributor

wnpllrzodiac commented May 13, 2020

Testing found that the UDP packet reception in the local area network (LAN) environment is relatively stable. However, in the public network environment, there are a lot of negative acknowledgments (NACK). The video playback is limited to only one frame and freezes for several seconds. Is the UDP packet restricted by the internet service provider (ISP)? Or is the UDP packet size exceeding the maximum transmission unit (MTU) and being dropped?

TRANS_BY_GPT3

@wnpllrzodiac
Copy link
Contributor

wnpllrzodiac commented May 13, 2020

Took a look, there are still 12k big packages like this, I guess they were directly discarded from the public network...

1640
8776
518
520
26
520
78
523
11899

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented May 13, 2020

@wnpllrzodiac SRS is divided into subpackages, with a maximum size of 1500. The 12k package you saw, did you capture it with Wireshark? Can you provide the Wireshark capture file?

TRANS_BY_GPT3

@wnpllrzodiac
Copy link
Contributor

wnpllrzodiac commented May 14, 2020

Sorry, I made a mistake. It's the total length that is so large. The individual packet sizes before that are normal.
This is a packet I captured on the server side, filtered out UDP.

Image

TRANS_BY_GPT3

@wnpllrzodiac
Copy link
Contributor

wnpllrzodiac commented May 14, 2020

This is the UDP captured by the client in the local area network.
Image

TRANS_BY_GPT3

@wnpllrzodiac
Copy link
Contributor

wnpllrzodiac commented May 14, 2020

The result of the public network test is very unstable.
I turned off NACK notification, otherwise the server logs keep showing NACK.
When playing the page, it takes more than 10 seconds to see one frame, and then it freezes for another 10 seconds.
The left side is the server's packet capture, and the right side is the client's packet capture. Except for the first UDP packet, the sizes don't match at all. I don't know where the data got messed up.

rtc_server {
    enabled         on;
    # Listen at udp://8000
    listen          8000;
    #
    # The $CANDIDATE means fetch from env, if not configed, use * as default.
    #
    # The * means retrieving server IP automatically, from all network interfaces,
    # @see https://github.com/ossrs/srs/issues/307#issuecomment-599028124
    candidate       1.2.3.4 server public IP; #$CANDIDATE;
    #sendmmsg 1;
    #merge_nalus off;
}

vhost __defaultVhost__ {
    rtc {
        enabled     on;
        bframe      discard;
    }
    nack {
        enabled off;
    }
}

Image

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented May 14, 2020

Supporting NACK and TWCC is currently in progress, please refer to the official website History for more information. The program structure is currently being adjusted.
WebRTC is not as easy to handle as live streaming, so please be patient.

TRANS_BY_GPT3

@wnpllrzodiac
Copy link
Contributor

wnpllrzodiac commented May 14, 2020

@winlinvip Okay, thank you for your hard work!

In LAN mode, both the server and client's UDP packets are one-to-one.

Image

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Sep 4, 2021
@winlinvip winlinvip added the WebRTC WebRTC, RTC2RTMP or RTMP2RTC. label Sep 4, 2021
@winlinvip winlinvip added this to the 4.0 milestone Sep 4, 2021
@dengzhengxiong

This comment was marked as off-topic.

@winlinvip winlinvip changed the title srs分发webrtc失败,流无法播放 srs distribution of webrtc failed, the stream cannot be played Jul 27, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TransByAI Translated by AI/GPT. WebRTC WebRTC, RTC2RTMP or RTMP2RTC.
Projects
None yet
Development

No branches or pull requests

6 participants