Dear Friends,
You can check RTMP Source is live or not using socket programming, but that will not give you exact output. Today I have tried Linux utility “rtmpdump” to test & check RTMP Source it produced quite interesting results on command line….
# rtmpdump -v -r rtmp://giraldatvlivefs.fplive.net/giraldatvlive-live/stream001 -o /tmp/rtmp-checker.log
<?php /* * * RTMPChecker - by S V N L A B S () (www.svnlabs.com/blogs) * You can use and modify this code as long as the above reference to me still exists ;) * */ if(isset($_REQUEST['stream']) && $_REQUEST['stream']!="") { exec("/usr/bin/rtmpdump -V -v -r '".$_REQUEST['stream']."' -o /tmp/rtmp-checker.log 2>&1", $pp); echo implode("<br>", $pp); } ?> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Check RTMP is live or not?</title> </head> <body> <form name="rtmp" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> <input type="text" name="stream" value="rtmp://164.100.49.14:80/live/dd2" /><br /> <input type="submit" name="check" value="check" /> </form> </body> </html>
OR You can use ffprobe:
# ffprobe -v quiet -print_format json -show_streams rtmp://[server-ip-address]/stream
Output: You have to download few seconds of the stream and then get return code 1 if the command failed or 0 JSON string detected streams on success.
Night is longer than day for those who dream & Day is longer than nights for those who MAKE their DREAMS come true…