Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Check RTMP Live stream is on or off

Tags:

php

ffmpeg

rtmp

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]: http://i.stack.imgur.com/ZrTco.png

I'm looking for solutions with ffmpeg, or something else.

like image 833
ITit superpower Avatar asked Jul 16 '15 10:07

ITit superpower


People also ask

How does RTMP live streaming work?

The Handshake– The process of RTMP live streaming begins with a handshake between the client wishing to stream media and the online video platform/live streaming server delivering that video or audio content. It involves the following steps:

How do I Find my RTMP url and stream key?

Select the Connect (RTMP) tab to get your RTMP URL and Stream Key. To find your RTMP information for YouTube, log into your YouTube account then navigate to CREATE > Go live. You will then see the following screen: Note that this does not impact the privacy of your stream on Vimeo.

What is RTMP and what is it for?

But what is RTMP anyway? Real Time Messaging Protocol developed by ADOBE for live streaming. It is mainly used for low latency, reduced buffering, adaptive bitrate streaming, and to fast-forward/rewind your video streams. This blog will tell you the pros and cons of RTMP if it is used by the TCP or UDP, and the difference between RTMP vs. HTTP.

What is the difference between RTMP and HLS?

RTMP transmits the video from the encoder to the online video platform. HLS transmits the video from the online video platform to the viewers’ devices. In order to prepare for a smooth live stream, you have to make sure all of your RTMP settings are properly configured.


1 Answers

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.

like image 72
aergistal Avatar answered Oct 10 '22 13:10

aergistal