I want to check 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 satisfied with the result because it doesn't always work, and generates a random string as a result.
![So some time i am facing this type of error. any perfect solution for this.?][1] [1]: https://i.sstatic.net/ZrTco.png
I'm looking for solutions with ffmpeg, or something else.
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.