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

How to implement reconnection after an RTSP stream capture does not report an error? #3972

Open
djkcyl opened this issue Mar 4, 2024 · 1 comment
Assignees
Labels
Codec HEVC, FFmpeg for ingesting, trascoding or codec. TransByAI Translated by AI/GPT.

Comments

@djkcyl
Copy link

djkcyl commented Mar 4, 2024

Describe the bug
When an RTSP stream is interrupted due to network issues or abnormalities in the device pulling the stream, it cannot reconnect without restarting the SRS to restore functionality.

Version
SRS/6.0.113

To Reproduce
Steps to reproduce the behavior:

  1. Initiate RTSP stream pulling.
  2. Restart the streaming source device (Hikvision camera).
  3. SRS fails to re-establish connection.

Config

root@a60:~# cat srs/trunk/conf/aunly.conf 

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

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

http_api {
    enabled on;
    listen 8180;
}

stats {
    network 0;
}

rtc_server {
    enabled on;
    listen 8000; # UDP port
    candidate 1.1.1.1;
    tcp {
        enabled on;
        listen 8000;
    }
    protocol all;
}

vhost __defaultVhost__ {
    # tcp_nodelay on;
    # min_latency on;
    # hls {
    #     enabled         off;
    #     hls_fragment    2;
    #     hls_window      5;
    # }
    rtc {
        enabled on;
        rtmp_to_rtc on;
        rtc_to_rtmp on;
        keep_bframe off;
    }
    http_remux {
        enabled on;
        mount [vhost]/[app]/[stream].flv;
        # mount [vhost]/[app]/[stream].ts;
    }

    ingest {
        enabled      on;
        input {
            type    stream;
            url     rtsp://admin:[email protected]:8554/Streaming/Channels/101;
        }
        ffmpeg      ./objs/ffmpeg/bin/ffmpeg;
        engine {
            enabled          on;
            perfile {
                rtsp_transport tcp;
            }
            vcodec copy;
            acodec copy;
            output          rtmp://127.0.0.1:[port]/live/live_1?vhost=[vhost];
        }
    }
}

TRANS_BY_GPT4

@winlinvip winlinvip changed the title rtsp 拉流采集不会报错后重连? How to implement reconnection after an RTSP stream capture does not report an error? Mar 4, 2024
@winlinvip winlinvip added TransByAI Translated by AI/GPT. Codec HEVC, FFmpeg for ingesting, trascoding or codec. labels Mar 4, 2024
@winlinvip
Copy link
Member

Actually, this bug is caused by FFmpeg failing to reconnect when the RTSP stream is blocked while being pulled. Therefore, you need to modify SRS to detect this issue and restart FFmpeg when the RTSP stream pulling is blocked. We have implemented this feature in the SRS stack camera streaming. We monitor FFmpeg's log, check the time, and the speed rate. If any exceptions are detected, we restart the FFmpeg process. Thus, you can simply switch to using the SRS stack instead. We have already done this.

If you insist on using the SRS media server, you will need to patch the ingest feature, and we would be happy to accept such a patch. However, we currently do not have the time to do this ourselves, especially since we have already implemented it in the SRS stack. Therefore, this feature in SRS is not a high priority for us.

@winlinvip winlinvip self-assigned this Mar 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Codec HEVC, FFmpeg for ingesting, trascoding or codec. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

2 participants