• 12
name

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191

Backtrace:

File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

How to Check RTMP Live stream is on or off

I want tocheck RTMP live stream is on or off for mic.

I have used RTMP DUMP

exec("/usr/bin/rtmpdump -V -v -r rtmp://www.exapmle.com/etc./13/mic1 -o /tmp/rtmp-checker.log 2>&1", $pp);

I have found this trick from http://blog.svnlabs.com/how-to-check-rtmp-source-stream-is-live-or-not/

But i am not Satisfy with result because some time its not working and generates random string as result.

So some time i am facing this type of error. any perfect solution for this.? IF YOU have any other solution Using FFMPEG OR OTHER then you are most welcome.

You can use ffprobe:

ffprobe -v quiet -print_format json -show_streams rtmp://example.com/stream

You'll get a return code 1 if the command failed or 0 and a JSON string containing the detected streams on success:

{
    "index": 1,
    "codec_name": "aac",
    "codec_long_name": "AAC (Advanced Audio Coding)",
    "profile": "LC",
    "codec_type": "audio",
    ...
}

This is a basic test, if you want to go further than that you could download a few seconds of the stream, validate it with ffprobe, run silencedetect on it etc.

  • 15
Reply Report
      • 2
    • I get the Response as you have mention for the rtmp in which music is on but it continuously processing and not get any response for the rtmp When my mic is off. if I on the mic than I get the response like yours. can you please explain reason and solution?.. Thanks
      • 2
    • You can try lowering -probesize (in bytes, default 5 mb). If it still gets stuck forever then the alternative is to use the linux timeout command: timeout 10s ffprobe .... It will return 124 if the command timeouts, in which case you raise an alert and check the stream.
    • Is it nessesary to include the -print_format json and the -show_streams options? After a some tests it looks like to me that the method works even if you rely on the exitcode exclusively, while omitting both options.
      • 2
    • @GergelyLukacsy It's not necessary if you don't need stream information. The question was about a microphone stream thus the check for an audio stream.

Warm tip !!!

This article is reproduced from Stack Exchange / Stack Overflow, please click

Trending Tags

Related Questions