php - How to Check RTMP Live stream is on or off -


i want tocheck rtmp live stream on or off 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 trick http://blog.svnlabs.com/how-to-check-rtmp-source-stream-is-live-or-not/

but not satisfy result because time not working , generates random string result.

so time facing type of error. perfect solution this.? if have other solution using ffmpeg or other welcome.

you can use ffprobe:

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

you'll return code 1 if command failed or 0 , json string containing detected streams on success:

{     "index": 1,     "codec_name": "aac",     "codec_long_name": "aac (advanced audio coding)",     "profile": "lc",     "codec_type": "audio",     ... } 

this basic test, if want go further download few seconds of stream, validate ffprobe, run silencedetect on etc.


Comments