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

4.0 release: When using ffprobe to pull the same rtmp stream from edge twice in a row, the second ffprobe command freezes and does not return. #2628

Closed
chenminnj opened this issue Sep 23, 2021 · 6 comments
Assignees
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Milestone

Comments

@chenminnj
Copy link

chenminnj commented Sep 23, 2021

  1. SRS version: 4.0 release
  2. Operating environment: Ubuntu 20.04.2 LTS

Printed some information,
Found that when the second ffprobe command successfully connected to RTMP,
After the new coroutine finished executing "SrsLiveSource::create_consumer",
The original coroutine, which was interrupted by the new connection and then awakened, continued to execute the "SrsPlayEdge::on_all_client_stop()" method,
Resulting in the edge state being set to "init",
I speculate that at this point, the edge does not pull the stream from the master node, which causes the second ffprobe command to freeze because it did not receive the RTMP stream.
The log information is as follows:
image

Made some attempts to modify:

  1. Pass the lock instance from SrsLiveSourceManager to SrsLiveSource when creating a new SrsLiveSource object.
  2. Add SrsLocker( lock ) at the beginning of the SrsLiveSource::on_consumer_destroy method.

The problem has been resolved, but the second time it still takes 3-4 seconds for the return of the ffprobe command (the first ffprobe command returns instantly).

I don't have a deep understanding of SRS, so I'm not sure if there are any issues with this modification or if there is a better way to handle it.

TRANS_BY_GPT3

@winlinvip winlinvip self-assigned this Sep 23, 2021
@winlinvip winlinvip added the Bug It might be a bug. label Sep 23, 2021
@winlinvip winlinvip added this to the 4.0 milestone Sep 23, 2021
@winlinvip
Copy link
Member

winlinvip commented Sep 23, 2021

After taking a look, there is only a rough reproduction method. Could you please write down the simplest steps to reproduce the issue?

TRANS_BY_GPT3

@chenminnj
Copy link
Author

chenminnj commented Sep 24, 2021

Steps to reproduce:

  1. Set up two SRS instances, one as master and the other as edge (the conf files should be similar to the example, with IP and Port modifications).

  2. Use ffmpeg to push an RTMP stream to the edge.
    ffmpeg -stream_loop -1 -re -i xx.flv -c copy -acodec aac -f flv rtmp://xx:1935/live/1
    Media file information for xx.flv is as follows:
    Metadata:
    creator : Coded
    metadatacreator : Yet Another Metadata Injector for FLV - Version 1.9
    canSeekToEnd : false
    videosize : 85401543
    audiosize : 8592688
    lastkeyframetimestamp: 390
    lastkeyframelocation: 93879313
    encoder : Lavf58.29.100
    Duration: 00:06:31.57, start: 0.000000, bitrate: 1174 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1024 kb/s, 29 fps, 29 tbr, 1k tbn, 58 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s

  3. Continuously use ffprobe to pull RTMP stream from edge.
    ffprobe rtmp://xx:1935/live/1

  • a. The first execution of the above ffprobe command returns normally and produces correct results.

  • b. Then, quickly executing the command again causes the ffprobe command to freeze and not return.

  • c. If the above ffprobe command is executed after a certain interval of time (approximately 10 seconds or more) following the first execution, the second ffprobe command also returns normally.

  • I have only seen a rough reproduction method. Could you please provide the simplest steps to reproduce the issue?

TRANS_BY_GPT3

@wenjiegit
Copy link
Contributor

wenjiegit commented Nov 1, 2021

Reproduction steps: 1. Set up two SRS instances, master and edge (conf files are similar to the example, with IP Port modifications). 2. Use ffmpeg to push an rtmp stream to the edge: ffmpeg -stream_loop -1 -re -i xx.flv -c copy -acodec aac -f flv rtmp://xx:1935/live/1 The media file information for xx.flv is as follows: Metadata: creator: Coded metadatacreator: Yet Another Metadata Injector for FLV - Version 1.9 canSeekToEnd: false videosize: 85401543 audiosize: 8592688 lastkeyframetimestamp: 390 lastkeyframelocation: 93879313 encoder: Lavf58.29.100 Duration: 00:06:31.57, start: 0.000000, bitrate: 1174 kb/s Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1024 kb/s, 29 fps, 29 tbr, 1k tbn, 58 tbc Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s

  1. Continuously use ffprobe to pull rtmp stream from the edge: ffprobe rtmp://xx:1935/live/1 a. The first execution of the above ffprobe command returns normally and the result is correct. b. Then quickly execute the command again, the ffprobe command freezes and does not return. c. If the command is executed again after a certain interval of time (approximately 10 seconds or more) following the first execution of the ffprobe command, the second ffprobe command also returns normally.

After reviewing, there is only a rough reproduction method. Could you please provide the simplest reproduction steps?

Please provide two example configuration files for SRS. Thank you.

TRANS_BY_GPT3

@retamia
Copy link
Contributor

retamia commented Nov 15, 2021

I have also encountered it. Our transcoding system uses ffprobe first, then ffmpeg. The transcoding speed of ffmpeg is only 0.003 times, and then it times out. Removing ffprobe solves the issue. Only pulling once, pulling the stream twice in a short period of time will cause the second stream to freeze.

TRANS_BY_GPT3

@chenminnj
Copy link
Author

chenminnj commented Nov 30, 2021

ffprobe rtmp://xx:1935/live/1

Directly use edge.conf and origin.conf under trunk/conf.

Reproduction steps:

  1. Set up two SRS instances, master-edge (conf files are basically the same as the sample, with IP Port modifications).
  2. Use ffmpeg to push an rtmp stream to the edge:
    ffmpeg -stream_loop -1 -re -i xx.flv -c copy -acodec aac -f flv rtmp://xx:1935/live/1
    Media file information for xx.flv is as follows:
    Metadata:
    creator: Coded metadatacreator: Yet Another Metadata Injector for FLV - Version 1.9 canSeekToEnd: false videosize: 85401543 audiosize: 8592688 lastkeyframetimestamp: 390 lastkeyframelocation: 93879313 encoder: Lavf58.29.100
    Duration: 00:06:31.57, start: 0.000000, bitrate: 1174 kb/s
    Stream #0:0: Video: h264 (High), yuv420p(progressive), 1280x720 [SAR 1:1 DAR 16:9], 1024 kb/s, 29 fps, 29 tbr, 1k tbn, 58 tbc
    Stream #0:1: Audio: aac (LC), 48000 Hz, stereo, fltp, 128 kb/s
  1. Continuously use ffprobe to pull the rtmp stream from the edge:
    ffprobe rtmp://xx:1935/live/1
    a. The first execution of the above ffprobe command returns normally with correct results.
    b. Then quickly execute the command again, the ffprobe command freezes and does not return.
    c. If there is a time interval between the first execution of the ffprobe command (approximately 10 seconds or more), the second ffprobe command also returns normally.

I have only provided a rough reproduction method. Could you please provide the simplest reproduction steps?

Please provide the configuration files for the two SRS instances. Thank you.

The configuration files are directly used from trunk/conf, namely edge.conf and origin.conf. Please refer to the compressed file below.
config.zip

TRANS_BY_GPT3

@winlinvip
Copy link
Member

winlinvip commented Dec 21, 2021

Reproduction path: #2594 (comment)

Thank you @retamia

I closed this issue, dup to #2594

TRANS_BY_GPT3

@winlinvip winlinvip modified the milestones: 4.0, 5.0 Dec 21, 2021
@winlinvip winlinvip changed the title 4.0release:从edge连续两次使用ffprobe拉同一rtmp流,第二次ffprobe命令僵住不返回 4.0 release: When using ffprobe to pull the same rtmp stream from edge twice in a row, the second ffprobe command freezes and does not return. Jul 28, 2023
@winlinvip winlinvip added the TransByAI Translated by AI/GPT. label Jul 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug It might be a bug. TransByAI Translated by AI/GPT.
Projects
None yet
Development

No branches or pull requests

4 participants