kerberos-io / machinery

(DEPRECATED) An open source image processing framework, which uses your USB-, IP- or RPi-camera to recognize events (e.g. motion).
https://www.kerberos.io
490 stars 103 forks source link

Can't Connect to RTSP IP Camera #224

Open ArtemM opened 3 years ago

ArtemM commented 3 years ago

I'm evaluating kerberos.io and successfully connected to one of my cameras (Hikvision). For testing purposes I installed RTSP server on Android device and can't connect there.

Details Android server: RTSP Camera Server V1.10 Kerberos.io "installation" is in docker. E.g. (ports might differ): docker run --name camera2 -p 81:80 -p 8890:8889 -d kerberos/kerberos

Error: 06/03/2021 16:38:19.784 ERROR [trivial] OpenCV : can't open url of ip camera Application log/configuration: https://pastebin.com/mgjF53P1

Actions performed Ensured that server is visible from container:

root@b0ffbf9d0df9:/# telnet 192.168.1.106 5554
Trying 192.168.1.106...
Connected to 192.168.1.106.
Escape character is '^]'.

Tried to adjust encoding: 2021-03-06 19 00 50

Tried to connect from VLC with very same URL (stream works) Tried to set up from scratch on a different host machine (same behavior, does not work)

ArtemM commented 3 years ago

Probably issues are somewhere else (OpenCV? Streaming server?). I guess this issue could be closed as irrelevant to kerberos.io unless someone is willing to investigate further and/or there are obvious steps I could try.

Just in case will describe a "proof" that excludes kerberos.io from the equation:

  1. I put a python file which saves rtsp to my host machine: https://gist.github.com/ArtemM/3e92d8138437eac9d214690c143df604 (note that rtsp URL should be changed to one which corresponds target environment)

  2. From the same folder I run OpenCV docker image with ffmpeg docker run --rm -it -v $PWD:/out borda/docker_python-opencv-ffmpeg /bin/bash

  3. and then from within a container root@6f4ca7f33b06:/out# python ./opencv_capture.py

Result: With "regular" rtsp camera (mentioned Hikvision) it outputs playable file while with the stream from Android it gives an error:

[rtsp @ 0x5566161fe700] Nonmatching transport in server reply
[ WARN:0] global /opencv/modules/videoio/src/cap_gstreamer.cpp (501) isPipelinePlaying OpenCV | GStreamer warning: GStreamer: pipeline have not been created 
[ERROR:0] global /opencv/modules/videoio/src/cap.cpp (140) open VIDEOIO(GSTREAMER): raised OpenCV exception:                                                 

OpenCV(4.5.1) /opencv/modules/videoio/src/cap_gstreamer.cpp:764: error: (-215:Assertion failed) uridecodebin in function 'open'                              

[ERROR:0] global /opencv/modules/videoio/src/cap.cpp (561) open VIDEOIO(GSTREAMER): raised OpenCV exception:                                                 

OpenCV(4.5.1) /opencv/modules/videoio/src/cap_gstreamer.cpp:1427: error: (-215:Assertion failed) frameSize.width > 0 && frameSize.height > 0 in function 'open'

[ERROR:0] global /opencv/modules/videoio/src/cap.cpp (561) open VIDEOIO(CV_IMAGES): raised OpenCV exception:                                                 

OpenCV(4.5.1) /opencv/modules/videoio/src/cap_images.cpp:253: error: (-5:Bad argument) CAP_IMAGES: can't find starting number (in the name of file): output.avi in function 'icvExtractPattern'

ffplay and VLC are playing stream (ffplay complying on something in the console but still playing, probably vlc does the same but I only run from GUI).

I thought that the potential cause could be WiFi connectivity issues but another configuration streaming over WiFi from Android works. Namely GoPro Android application connected to nginx-rtmp-docker streaming to kerberos.io container. That does not fully exclude "WiFi issue" scenario but reduces probability quite a bit.