google-coral / example-object-tracker

Apache License 2.0
105 stars 32 forks source link

rtsp source is not working #5

Open barslan16 opened 3 years ago

barslan16 commented 3 years ago

Could you give a command line example of how to change video source to rtsp? Although I tried many times, I could not run this command.

Thank you very much in advance, looking forward to your I also add the error I got below.

WhatsApp Image 2021-03-05 at 15 15 30

manoj7410 commented 3 years ago

@barslan16 Maybe you can try to test your rtsp-url on a gst-launch-1.0 first?

gst-launch-1.0 rtspsrc location=

barslan16 commented 3 years ago

Thank you very much for your advice. I tried what you said. When I run the code below, streaming is happening. gst-launch-1.0 rtspsrc location='rtsp://admin:1234@192.168.1.143/H264?ch=1&subtype=0' ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

However, when I run the code below, I get an error. I'm writing the error and code below.

python3 detect.py --tracker sort --videosrc rtsp://admin:1234@192.168.1.143/H264?ch=1&subtype=0 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

Error:

Gstreamer pipeline: rtspsrc location=rtsp://admin:1234@192.168.1.143/H264?ch=1 ! tee name=t t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=300,height=225 ! videobox name=box autocrop=true ! video/x-raw,format=RGB,width=300,height=300 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! rsvgoverlay name=overlay ! videoconvert ! ximagesink sync=false

Warning: gst_parse_error: Delayed linking failed. (7): ./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstTee named t Error: gst-stream-error-quark: Internal data stream error. (1): gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: streaming stopped, reason not-linked (-1)

I would be glad if you could help.

barslan16 commented 3 years ago

Thank you very much for your advice. I tried what you said. When I run the code below, streaming is happening. gst-launch-1.0 rtspsrc location='rtsp://admin:1234@192.168.1.143/H264?ch=1&subtype=0' ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

However, when I run the code below, I get an error. I'm writing the error and code below.

python3 detect.py --tracker sort --videosrc rtsp://admin:1234@192.168.1.143/H264?ch=1&subtype=0 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

Error:

Gstreamer pipeline: rtspsrc location=rtsp://admin:1234@192.168.1.143/H264?ch=1 ! tee name=t t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! videoscale ! video/x-raw,width=300,height=225 ! videobox name=box autocrop=true ! video/x-raw,format=RGB,width=300,height=300 ! appsink name=appsink emit-signals=true max-buffers=1 drop=true t. ! queue max-size-buffers=1 leaky=downstream ! videoconvert ! rsvgoverlay name=overlay ! videoconvert ! ximagesink sync=false

Warning: gst_parse_error: Delayed linking failed. (7): ./grammar.y(510): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstTee named t Error: gst-stream-error-quark: Internal data stream error. (1): gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc0: streaming stopped, reason not-linked (-1)

I would be glad if you could help.

@barslan16 Maybe you can try to test your rtsp-url on a gst-launch-1.0 first?

gst-launch-1.0 rtspsrc location=

manoj7410 commented 3 years ago

@barslan16 Is there an HDMI monitor connected ? And on which platform are you trying to run this demo ?

barslan16 commented 3 years ago

@barslan16 Is there an HDMI monitor connected ? And on which platform are you trying to run this demo ?

@manoj7410 I am using rpi4 and coral, I could not run it when connected with hdmi, nor could I run it when connected via vnc player. The brand of the camera I use: Qmax IP camera

highfreq commented 3 years ago

Same problem here, i can get a feed with:

gst-launch-1.0 rtspsrc location=rtsp://admin:password@10.8.0.4:554/videoinput_1:0/h264_2/media.stm ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

but following gives error:

python3 detect.py --tracker sort --videosrc rtsp://admin:password@10.8.0.4:554/videoinput_1:0/h264_2/media.stm

Warning: gst_parse_error: Delayed linking failed. (7): ./grammar.y(506): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstTee named t Error: gst-stream-error-quark: Internal data stream error. (1): gstbasesrc.c(3072): gst_base_src_loop (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc1: streaming stopped, reason not-linked (-1)

Following works using laptop webcam:

python3 detect.py --tracker sort

highfreq commented 3 years ago

Any help please????

kiteklan commented 2 years ago

try to remove the password auth. from the camera menu

highfreq commented 2 years ago

Tried without password, same error. Must be something in the pipeline that they build in the application that is broken because the following works: gst-launch-1.0 rtspsrc location=rtsp://admin:password@10.8.0.4:554/videoinput_1:0/h264_2/media.stm ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert ! xvimagesink

kiteklan commented 2 years ago

Quick note gst-launch-1.0 rtspsrc location="rtsp://admin:xxxxx@192.168.1.105:554/cam/realmonitor?channel=2&subtype=0" Using double quotes may help, I managed to run with this , but still issues with buffer

highfreq commented 2 years ago

Can't believe still the same problem after months. Could someone from google fix it please?

jlpoolen commented 2 years ago

I'm looking into this and noticed that the video used for the two methods (invoked with parameters: --device and --stream) differ... and they differ from the original presumably borrowed by Google from pixabay.

See http://salemdata.net/ai/coral/video_device_comparisons.html

I think the complexity of gstreamer and video, in general, is intimidating, even for the people supporting the functionality of the coral chip.

jlpoolen commented 2 years ago

These dot diagrams representing runs of Google's default demonstration programs edgetpu_demo --stream and edgetpu_demo --device may be helpful in analyzing the flow: edgetpu_demo_device_20220423_Sat_0748 edgetpu_demo_stream_20220423_Sat_0743

jiekechoo commented 2 years ago

It works for me :

python3 detect.py --videosrc "rtsp://192.168.120.58/ch01_sub.h264 ! rtph264depay ! h264parse ! avdec_h264 ! videoconvert"

jvsinclair commented 1 year ago

I have the same issue. I was able to use ffmpeg / vlc to view the stream with no issue:

ffplay -i rtsp://1234:1234@192.168.123.31/live 

I then tried the various gst-launch commands, for example:

gst-launch-1.0 rtspsrc location="rtsp://1234:1234@192.168.123.31/live" ! videoconvert ! autovideosink

Every time, no matter the options selected, I get the following error:

WARNING: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0: Delayed linking failed.
Additional debug info:
gst/parse/grammar.y(540): gst_parse_no_more_pads (): /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0:
failed delayed linking some pad of GstRTSPSrc named rtspsrc0 to some pad of GstVideoConvert named videoconvert0
ERROR: from element /GstPipeline:pipeline0/GstRTSPSrc:rtspsrc0/GstUDPSrc:udpsrc2: Internal data stream error.

Reading through some forums is seem that on Debian there are some issues with non-free code for RTSP so the decision was made to pull it: Debian bug #982299 . Not sure it its related, but a lot of the tools I tried to use in testing this ran into issues because of RTSP being pulled (like in VLC on debian).

Then I came across this old Stack overflow article so I tried it:

gst-launch-1.0 uridecodebin uri="rtsp://1234:1234@192.168.123.31/live" ! videoconvert ! autovideosink

and it works great

Based on that, here is how I fixed it. In gstreamers.py line 219, I updated it to useuridecodebin instead of rtspsrc

    elif videosrc.startswith('http'):
        PIPELINE = 'souphttpsrc location=%s'%videosrc
    #elif videosrc.startswith('rtsp'):
    #    PIPELINE = 'rtspsrc location="%s"'%videosrc
    elif videosrc.startswith('rtsp'):
        PIPELINE = 'uridecodebin uri="%s"'%videosrc
    else:
        demux =  'avidemux' if videosrc.endswith('avi') else 'qtdemux'

With that change you can use a password protected rtsp stream. Works with Wyze v3 camera running rtsp firmware and VLC running on Mac creating a rtsp stream. Needs to be tested more before creating a pull request with this change but it works on my Debian 11 server.