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.86k stars 5.29k forks source link

srsv6.0-d0, flv.js and mpegts.js occasionally display a black screen when playing videos. #3752

Closed lin557 closed 7 months ago

lin557 commented 11 months ago

Note: Please read FAQ before file an issue, see #2716

Description

After updating from srsv4.0-r1 to srsv6.0-d0, there is occasionally a black screen issue when the web client requests to play http-flv first and then starts streaming. This issue occurs with both flv.js and mpegts.js. The mpegts.js log shows that the black screen occurs because the AVCDecoderConfigurationRecord is not received, only the audio stream. When the web client closes the player and requests http-flv again, it can play normally.

  1. SRS Version: 6.0-d0, 5.0.166, 5.0.170

After testing, none of the following versions will have any issues.

v4.0-r1 v4.0.r4 v4.0-r5 v5.0.157 v5.0.89 v5.0.21

  1. SRS Log:
[2023-08-03 09:48:15.600][INFO][1][1b3hy9kt] RTMP client ip=172.22.0.4:56450, fd=52
[2023-08-03 09:48:15.604][INFO][1][1b3hy9kt] simple handshake success.
[2023-08-03 09:48:15.604][INFO][1][1b3hy9kt] connect app, tcUrl=rtmp://srs8535:1935/live, pageUrl=, swfUrl=rtmp://srs8535:1935/live, schema=rtmp, vhost=srs8535, port=1935, app=live, args=null
[2023-08-03 09:48:15.604][INFO][1][1b3hy9kt] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=60000, out.chunk=128
[2023-08-03 09:48:15.645][INFO][1][1b3hy9kt] client identified, type=fmle-publish, vhost=srs8535, app=live, stream=6013_4, param=, duration=0ms
[2023-08-03 09:48:15.645][INFO][1][1b3hy9kt] connected stream, tcUrl=rtmp://srs8535:1935/live, pageUrl=, swfUrl=rtmp://srs8535:1935/live, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=6013_4, param=, args=null
[2023-08-03 09:48:15.645][INFO][1][1b3hy9kt] source url=/live/6013_4, ip=172.22.0.4, cache=1/2500, is_edge=0, source_id=/
[2023-08-03 09:48:15.685][INFO][1][1b3hy9kt] ignore disabled exec for vhost=__defaultVhost__
[2023-08-03 09:48:15.685][INFO][1][1b3hy9kt] set fd=52 TCP_NODELAY 0=>1
[2023-08-03 09:48:15.685][INFO][1][1b3hy9kt] start publish mr=0/350, p1stpt=20000, pnt=10000, tcp_nodelay=1
[2023-08-03 09:48:15.686][INFO][1][1b3hy9kt] got metadata, width=352, height=288, vcodec=7, acodec=2
[2023-08-03 09:48:15.686][INFO][1][1b3hy9kt] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 44100HZ), flv(16bits, 1channels, 44100HZ)
[2023-08-03 09:48:15.696][WARN][1][1b3hy9kt][11] VIDEO: Timestamp 3588=>0, may need mix_correct.
[2023-08-03 09:48:15.696][INFO][1][1b3hy9kt] 30B video sh, codec(7, profile=High, level=Other, 352x288, 0kbps, 0.0fps, 0.0s)
[2023-08-03 09:48:15.708][INFO][1][483h5r20] update source_id=5k26d597/5k26d597
[2023-08-03 09:48:15.709][INFO][1][483h5r20] FLV: write header audio=1, video=1, dinm=1, config=1/1/1
[2023-08-03 09:48:15.984][INFO][1][7285m592] update source_id=1b3hy9kt/1b3hy9kt
[2023-08-03 10:19:29.537][INFO][1][6g123471] HTTP #0 172.22.0.1:55640 GET http://mdvr/live/6013_7.flv, content-length=-1
[2023-08-03 10:19:29.538][INFO][1][6g123471] flv: source url=/live/6013_7, is_edge=0, source_id=/5777y9hg
[2023-08-03 10:19:29.538][INFO][1][6g123471] create consumer, active=0, queue_size=0.00, jitter=30000000
[2023-08-03 10:19:29.538][INFO][1][6g123471] FLV /live/6013_7.flv, encoder=FLV, mw_sleep=350ms, cache=0, msgs=128, dinm=1, guess_av=1/1/1
[2023-08-03 10:19:29.733][INFO][1][98zv63r8] Process: cpu=12.99%,182MB, threads=2
[2023-08-03 10:19:31.547][INFO][1][83f4rjv6] RTMP client ip=172.22.0.4:39640, fd=44
[2023-08-03 10:19:31.554][INFO][1][83f4rjv6] simple handshake success.
[2023-08-03 10:19:31.554][INFO][1][83f4rjv6] connect app, tcUrl=rtmp://srs8535:1935/live, pageUrl=, swfUrl=rtmp://srs8535:1935/live, schema=rtmp, vhost=srs8535, port=1935, app=live, args=null
[2023-08-03 10:19:31.554][INFO][1][83f4rjv6] protocol in.buffer=0, in.ack=0, out.ack=0, in.chunk=60000, out.chunk=128
[2023-08-03 10:19:31.594][INFO][1][83f4rjv6] client identified, type=fmle-publish, vhost=srs8535, app=live, stream=6013_7, param=, duration=0ms
[2023-08-03 10:19:31.595][INFO][1][83f4rjv6] connected stream, tcUrl=rtmp://srs8535:1935/live, pageUrl=, swfUrl=rtmp://srs8535:1935/live, schema=rtmp, vhost=__defaultVhost__, port=1935, app=live, stream=6013_7, param=, args=null
[2023-08-03 10:19:31.595][INFO][1][83f4rjv6] source url=/live/6013_7, ip=172.22.0.4, cache=1/2500, is_edge=0, source_id=/5777y9hg
[2023-08-03 10:19:31.635][INFO][1][83f4rjv6] ignore disabled exec for vhost=__defaultVhost__
[2023-08-03 10:19:31.635][INFO][1][83f4rjv6] set fd=44 TCP_NODELAY 0=>1
[2023-08-03 10:19:31.635][INFO][1][83f4rjv6] start publish mr=0/350, p1stpt=20000, pnt=10000, tcp_nodelay=1
[2023-08-03 10:19:31.636][INFO][1][83f4rjv6] got metadata, width=352, height=288, vcodec=7, acodec=2
[2023-08-03 10:19:31.639][INFO][1][83f4rjv6] 4B audio sh, codec(10, profile=LC, 1channels, 0kbps, 44100HZ), flv(16bits, 1channels, 44100HZ)
[2023-08-03 10:19:31.640][INFO][1][6g123471] update source_id=83f4rjv6/5777y9hg
[2023-08-03 10:19:31.640][INFO][1][6g123471] FLV: write header audio=1, video=0, dinm=1, config=1/1/1
[2023-08-03 10:19:31.641][WARN][1][83f4rjv6][11] VIDEO: Timestamp 138=>0, may need mix_correct.
[2023-08-03 10:19:31.641][INFO][1][83f4rjv6] 30B video sh, codec(7, profile=High, level=Other, 352x288, 0kbps, 0.0fps, 0.0s)
  1. SRS Config:
# the config for srs to dvr in session mode
# @see https://github.com/ossrs/srs/wiki/v3_CN_DVR
# @see full.conf for detail config.

listen              1935;
max_connections     1000;
#srs_log_tank        file;
#srs_log_file        ./objs/srs.log;

# 注意使用 docker 运行时 这里必须要设为 off
daemon              off;

http_api {
    enabled         on;
    listen          1985;
}

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

vhost __defaultVhost__ {

    hls {
        enabled         off;
        hls_fragment    5;
    }

    http_remux {
        # 启用http-flv
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
    }

    publish {
    #    mr off;
        # default: 5000 超时 srs 会主动断开推流者的连接
        normal_timeout 10000;
    }

}

Replay

Please describe how to replay the bug?

Step 1: Request http-flv first.

Step 2: Start pushing the stream.

Occasional phenomenon, probability less than 2%.

When testing different versions using the above process, a black screen playback issue occurs.

- v4.0-r1: Used consistently, no black screen issue.
- v4.0.r4: Tested over 1200 times, no black screen.
- v4.0-r5: Tested over 500 times, no black screen.
- v5.0.21: Tested over 500 times, no black screen.
- v5.0.89: Tested over 400 times, no black screen.
- v5.0.157: Tested over 300 times, no black screen.
- v5.0.166: Less than 100 occurrences, black screen issue observed.
- v5.0.170: Less than 50 occurrences, black screen issue observed.
- v6.0-48: Less than 100 occurrences, black screen issue observed.
- v6.0-d0: Less than 128 occurrences, black screen issue observed.

注:如果先rtmp推流,后再请求http-flv,不会出现上面的问题

Expect

Please describe your expectation.

TRANS_BY_GPT3

lin557 commented 7 months ago
vhost __defaultVhost__ {
    http_remux {
        enabled     on;
        mount       [vhost]/[app]/[stream].flv;
        drop_if_not_match off;
        has_audio on;
        has_video on;
        guess_has_av off;
    }
}
winlinvip commented 7 months ago

Why was it shut down? Has the problem been resolved?

TRANS_BY_GPT4