How to check RTMP Live stream on or off
I want the RTMP stream to be enabled or disabled for the microphone.
I 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 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 for a while its not working and it generates a random string as the result.
IF YOU have another solution using FFMPEG OR OTHER then you will be very pleased.
source to share
You can use ffprobe
:
ffprobe -v quiet -print_format json -show_streams rtmp://example.com/stream
You will receive a return code 1
if the command failed, or a 0
JSON string containing the streams found 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 you could load a few seconds of the stream, test it with ffprobe
, run silencedetect
on it, etc.
source to share