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.
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.