0

I'm able to play a rtsp stream from an ip camera in linux with following:

gst-launch -v rtspsrc location="rtsp://admin:pw@192.168.3.106/live1.sdp" name=demux demux. ! queue max-size-buffers=2 ! rtph264depay ! ffdec_h264 ! ffmpegcolorspace ! autovideosink sync=false

how do one checks if the rtsp stream is actually available over network before attempting to play. I want my stream playback to detect if rtsp stream is down, so that i will not attempt to play a stream until available.

sb32134
  • 426
  • 8
  • 19

1 Answers1

2

You would need to write a client application to do that, I don't think its possible on the command line. With the application you can try to play from the rtsp source and if it times out you can try again or provide a suitable message to the user that the stream is not available or retry.

Having said that there are many open source github projects with such a player for various platforms Android, Windows, Linux QT based etc. A simple google search with 'gstreamer rtsp viewer github' will list a lot.

Samer Tufail
  • 1,835
  • 15
  • 25
  • In my application, there is no user interaction, the app either plays an available stream for let's say 10 sec and move to next item or don't play it at all and just move to next item. – sb32134 Sep 09 '16 at 07:58
  • Well then you could a timer and check the pipeline state or the state of the rtspsrc element - if it starts playing stop the timer else move to the next and restart the timer. Another possibility is to look at the frames on the rtspsrc on one of the provided callbacks and stop the timer. Either way gstreamer does not provide a direct way to do this. – Samer Tufail Sep 09 '16 at 08:04
  • i was more of thinking if nmap is a good choice here? what if the ip camera is down in the network, there is no point in attempting to play something that is down. This is because, i still get a brief black screen before moving to next item. Its better if i don't attempt to play rtsp item at all. – sb32134 Sep 09 '16 at 08:10
  • 1
    you could write a simple (also examples available) for a ping request to check if the camera is up - if it is you should be able to ping it. http://www.boost.org/doc/libs/1_51_0/doc/html/boost_asio/example/icmp/ping.cpp - boost has a good example on this – Samer Tufail Sep 09 '16 at 08:13
  • i thought be ping, but ping on icmp requires root permission, so ping idea didn't seem to work. boost asio seems to be overkill or feels to big library to do just ping. – sb32134 Sep 09 '16 at 13:55
  • its entirely up to you, that was just an example. nmap would work equally well. – Samer Tufail Sep 09 '16 at 14:13