roflcoopter / viseron

Self-hosted, local only NVR and AI Computer Vision software. With features such as object detection, motion detection, face recognition and more, it gives you the power to keep an eye on your home, office or any other place you want to monitor.
MIT License
1.76k stars 179 forks source link

VISERON: FFprobe could not connect to stream. Output: {'error': {'code': -111, 'string': 'Connection refused'}} #768

Closed delfredd closed 2 months ago

delfredd commented 5 months ago

Hello, Can someone help me here:

I am having errors when I am trying to connect to my reolink cameras after configured on Viseron:

Viseron error

This is my configuration file:

Viseron Config.yaml.docx

thank you.

roflcoopter commented 5 months ago

Seems your camera is canceling the connection. Do you have any other software connected to the camera streams? Some cameras only allow a set number of open streams at any time

delfredd commented 5 months ago

Hi, roflcoopter Thanks for your help...In my network, I have 9 cameras, 6 integrated and monitored using Blue Iris. I am planning to migrate from Blue Iris to Viseron....., however, after reading your message, I fixed the configuration file trying to use two cameras that aren’t using any other software (Not connected through Blue Iris). I am still getting the same error. I don't know why I can't connect or why I am still having this error. I can't move on. Do you have any suggestions, please? Thanks!

roflcoopter commented 5 months ago

And you have no firewall in place that might block the connection?

delfredd commented 5 months ago

I am not using a firewall. but I can connect individually to a single camera through the IP address from any computer. The computer where I am configuring viseron is using Debian 12.

tms320 commented 5 months ago

I have the same problem:

[2024-06-19 20:55:05] [INFO    ] [viseron.components] - Setting up domain camera for component ffmpeg with identifier camera_2, attempt 2
[2024-06-19 20:55:05] [ERROR   ] [viseron.components.ffmpeg.stream.camera_2] - [tcp @ 0x5633778f70c0] Connection to tcp://10.42.0.139:554?timeout=0 failed: Connection refused
[2024-06-19 20:55:05] [ERROR   ] [viseron.components.ffmpeg.stream.camera_2] - rtsp://10.42.0.139:554/stream0: Connection refused
[2024-06-19 20:55:05] [ERROR   ] [viseron.components] - Domain camera for component ffmpeg is not ready. Retrying in 20 seconds. Error: FFprobe could not connect to stream. Output: {'error': {'code': -111, 'string': 'Connection refused'}}

Config of my camera:

    camera_2:  # This value has to be unique across all cameras
      name: Camera 2
      host: 10.42.0.139
      port: 554
      path: /stream0

I turned off authentification for RTSP stream, so there is no login/password. My network configuration:

image

Viseron installed on Debian 12 server. Server has two interfaces: wlo1 - main interface (wireless) connected to my main 'Network 1' via ISP-router. Camera 1 in this network works with Viseron without problems. The second ethernet interface 'enp2s0' is enslaved into network bridge using Network Manager:

image

Camera 2 connected to enp2s0 interface and has IP address 10.42.0.139. From inside Debian server I can ping both Camera 1 and Camera 2.

delfredd commented 4 months ago

Hi, roflcoopter,

Do you have any updates on this issue? Thx

roflcoopter commented 4 months ago

I dont sadly :( These errors are very hard for me to debug since i cannot reliable reproduce. Dont really know where to start...

Can you try to run this command and send me the output? docker exec -it viseron ffprobe -loglevel trace -print_format json -show_streams -show_error <RTSP URL HERE>

roflcoopter commented 4 months ago

Another question, if you specify width, height, fps, codec and audio_codec manually in the config so that FFprobe is skipped, does it work then? That would confirm the issue is with FFprobe only and not a networking issue

delfredd commented 4 months ago

Hi, roflcoopter,

this is the output: delfred@nvr:~$ docker exec -it viseron ffprobe -loglevel trace -print_format json -show_streams -show_error 192.168.50.117 permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/viseron/json": dial unix /var/run/docker.sock: connect: permission denied

delfredd commented 4 months ago

I can connect to the cameras without issues. typing the IP address in the web browser, I connect (Reolink Cameras)

See the configuration file below: (Please let me know if I am missing something)

Thanks for trying out Viseron!

This is a small walkthrough of the configuration to get you started.

There are far more components and options available than what is listed here.

See the documentation for the full list of configuration options.

Start by adding some cameras

ffmpeg: camera: camera_1: # This value has to be unique across all cameras name: Dogs View host: 192.168.50.117 port: 554 path: /h264Preview_01_main username: !secret camera_user password: !secret camera_pass fps: 15

camera_2:  # This value has to be unique across all cameras.
  name: Skimmer View
  host: 192.168.50.201
  port: 554
  path: /h264Preview_01_main
  username: !secret camera_user
  password: !secret camera_pass
  fps: 15

Then add an object detector

darknet:

object_detector:

cameras:

camera_1: # Attach detector to the configured camera_1 above

fps: 15

scan_on_motion_only: false # Scan for objects even when there is no motion

labels:

- label: person

confidence: 0.75

trigger_recorder: true

camera_2: # Attach detector to the configured camera_2 above

fps: 15

labels:

- label: person

confidence: 0.75

trigger_recorder: true

You can also use motion detection

mog2: motion_detector: cameras: camera_1: # Attach detector to the configured camera_2 above fps: 15 camera_2: # Attach detector to the configured camera_2 above fps: 15

To tie everything together we need to configure one more component.

nvr: camera_1: # Run NVR for camera_1 camera_2: # Run NVR for camera_2

Now you can restart Viseron and you should be good to go!

Thank You!!!

roflcoopter commented 4 months ago

Hi, roflcoopter,

this is the output: delfred@nvr:~$ docker exec -it viseron ffprobe -loglevel trace -print_format json -show_streams -show_error 192.168.50.117 permission denied while trying to connect to the Docker daemon socket at unix:///var/run/docker.sock: Get "http://%2Fvar%2Frun%2Fdocker.sock/v1.45/containers/viseron/json": dial unix /var/run/docker.sock: connect: permission denied

It's not actually running the command since it fails already at docker exec. Do you need to use sudo do run docker commands on your host?

delfredd commented 4 months ago

I am using casaOS. from casaOS I am getting to Viseron.

I am following this video exactly but it is not working for me.

https://www.youtube.com/watch?v=6ahtCpIoWU4&t=1304s

delfredd commented 4 months ago

Sorry, you were right, I was not using sudo.

This is what I got:

delfred@nvr:~$ sudo docker exec -it viseron ffprobe -loglevel trace -print_format json -show_streams -show_error 192.168.50.117 [sudo] password for delfred: ffprobe version 5.1.2 Copyright (c) 2007-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-vaapi --enable-libmfx --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 { [NULL @ 0x55862cc5b940] Opening '192.168.50.117' for reading [file @ 0x55862cc5c2c0] Setting default whitelist 'file,crypto,data' 192.168.50.117: No such file or directory "error": { "code": -2, "string": "No such file or directory" } }

roflcoopter commented 4 months ago

You need to use the full URL to the stream, so something like this: sudo docker exec -it viseron ffprobe -loglevel trace -print_format json -show_streams -show_error rtsp://USERNAME:PASSWORD@192.168.50.117/h264Preview_01_main

delfredd commented 4 months ago

Here you go.

I didn't not include the username and password in the output, but I included them when applied the command. I hope this output works and help to find the issue.

See below:

sudo docker exec -it viseron ffprobe -loglevel trace -print_format json -show_streams -show_error rtsp://USERNAME:PASSWORD@192.168.50.117/h264Preview_01_main [sudo] password for delfred: ffprobe version 5.1.2 Copyright (c) 2007-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-vaapi --enable-libmfx --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 { Probing rtsp score:100 size:0 [tcp @ 0x55d598719700] No default whitelist set [tcp @ 0x55d598719700] Original list of addresses: [tcp @ 0x55d598719700] Address ::1 port 554 [tcp @ 0x55d598719700] Address 127.0.0.1 port 554 [tcp @ 0x55d598719700] Interleaved list of addresses: [tcp @ 0x55d598719700] Address ::1 port 554 [tcp @ 0x55d598719700] Address 127.0.0.1 port 554 [tcp @ 0x55d598719700] Starting connection attempt to ::1 port 554 [tcp @ 0x55d598719700] Connection attempt to ::1 port 554 failed: Connection refused [tcp @ 0x55d598719700] Starting connection attempt to 127.0.0.1 port 554 [tcp @ 0x55d598719700] Connection attempt to 127.0.0.1 port 554 failed: Connection refused [tcp @ 0x55d598719700] Connection to tcp://:554?timeout=0 failed: Connection refused rtsp://USERNAME:PASSWORD@192.168.50.117/h264Preview_01_main: Connection refused "error": { "code": -111, "string": "Connection refused" } }

Thank you!

roflcoopter commented 4 months ago

What if you try udp? sudo docker exec -it viseron ffprobe -loglevel trace -rtsp_transport udp -print_format json -show_streams -show_error rtsp://USERNAME:PASSWORD@192.168.50.117:554/h264Preview_01_main

delfredd commented 4 months ago

Do you see any difference?

sudo docker exec -it viseron ffprobe -loglevel trace -rtsp_transport udp -print_format json -show_streams -show_error rtsp://USERNAME:PASSWORD@192.168.50.117:554/h264Preview_01_main [sudo] password for delfred: ffprobe version 5.1.2 Copyright (c) 2007-2022 the FFmpeg developers built with gcc 9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-vaapi --enable-libmfx --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100 { Probing rtsp score:100 size:0 [tcp @ 0x5588c4913780] No default whitelist set [tcp @ 0x5588c4913780] Original list of addresses: [tcp @ 0x5588c4913780] Address ::1 port 554 [tcp @ 0x5588c4913780] Address 127.0.0.1 port 554 [tcp @ 0x5588c4913780] Interleaved list of addresses: [tcp @ 0x5588c4913780] Address ::1 port 554 [tcp @ 0x5588c4913780] Address 127.0.0.1 port 554 [tcp @ 0x5588c4913780] Starting connection attempt to ::1 port 554 [tcp @ 0x5588c4913780] Connection attempt to ::1 port 554 failed: Connection refused [tcp @ 0x5588c4913780] Starting connection attempt to 127.0.0.1 port 554 [tcp @ 0x5588c4913780] Connection attempt to 127.0.0.1 port 554 failed: Connection refused [tcp @ 0x5588c4913780] Connection to tcp://:554?timeout=0 failed: Connection refused rtsp://USERNAME:PASSWORD@192.168.50.117:554/h264Preview_01_main: Connection refused "error": { "code": -111, "string": "Connection refused" } } delfred@nvr:~$

delfredd commented 4 months ago

by the way, just in case, I am using Debian 12,

roflcoopter commented 4 months ago

OS should not matter. Can you view the camera using something like VLC for instance?

delfredd commented 4 months ago

I tried to use VLC and ensured the protocol (RTSP) was active with #554 in the camera settings.

This is what I am getting:

Connection failed: VLC could not connect to "@:554". Your input can't be opened: VLC is unable to open the MRL 'rtsp://USERNAME:PASSWORD@192.168.50.117:554/h264Preview_01_main'. Check the log for details.

Thank you!

delfredd commented 3 months ago

Hi, I was able to connect to the camera using VLC, but I used this format first:

rtsp://192.168.50.117:554/h264Preview_01_main

Then,

I was asked for the authentication (USENAME & PASSWORD) , and then, after I input the info, I got into the camera view.

delfredd commented 3 months ago

I am trying to connect through viseron, I still have an error:

code': -111, 'string': 'Connection refused'}}

delfredd commented 3 months ago

I tried using VLC in Linux, but I am having issues. Wondering if you are aware?

I was searching and found this: See below:

Debian VLC builds do not support RTSP by Debian policy decision"

With a VLC SNAP-package it is possible to play rtsp-Streams.

And it looks like every program (mplayer, ffplay, vlc ... ) which was build for Debian has removed the rtsp-Streaming ability too.

any idea?

delfredd commented 3 months ago

I tried VLC on another Windows computer and I got a camera connection. (RTSP) streaming is working

I tried VLC also using Kali Linux, but I had an error connection. (RTSP) "VLC is unable to open the MRL 'rtsp://192.168.50.117:554/h264Preview_01_main.

Is there another package we must install in Linux OS to make this work?

delfredd commented 3 months ago

Hi Roflcoopter,

I have been trying different machines (Laptops) but still have issues with Viseron. The last thing I tried was installing ffmpeg and then trying to connect to the camera, but I am still getting this error:

ffplay rtsp://USERNAME:PASSWORD@192.168.50.117:554/h264Preview_01_main ffplay version 5.1.5-0+deb12u1 Copyright (c) 2003-2024 the FFmpeg developers built with gcc 12 (Debian 12.2.0-14) configuration: --prefix=/usr --extra-version=0+deb12u1 --toolchain=hardened --libdir=/usr/lib/x86_64-linux-gnu --incdir=/usr/include/x86_64-linux-gnu --arch=amd64 --enable-gpl --disable-stripping --enable-gnutls --enable-ladspa --enable-libaom --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --enable-libdav1d --enable-libflite --enable-libfontconfig --enable-libfreetype --enable-libfribidi --enable-libglslang --enable-libgme --enable-libgsm --enable-libjack --enable-libmp3lame --enable-libmysofa --enable-libopenjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librist --enable-librubberband --enable-libshine --enable-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libsvtav1 --enable-libtheora --enable-libtwolame --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx265 --enable-libxml2 --enable-libxvid --enable-libzimg --enable-libzmq --enable-libzvbi --enable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --disable-sndio --enable-libjxl --enable-pocketsphinx --enable-librsvg --enable-libmfx --enable-libdc1394 --enable-libdrm --enable-libiec61883 --enable-chromaprint --enable-frei0r --enable-libx264 --enable-libplacebo --enable-librav1e --enable-shared libavutil 57. 28.100 / 57. 28.100 libavcodec 59. 37.100 / 59. 37.100 libavformat 59. 27.100 / 59. 27.100 libavdevice 59. 7.100 / 59. 7.100 libavfilter 8. 44.100 / 8. 44.100 libswscale 6. 7.100 / 6. 7.100 libswresample 4. 7.100 / 4. 7.100 libpostproc 56. 6.100 / 56. 6.100

[tcp @ 0x7f55cc003a00] Connection to tcp://:554?timeout=0 failed: Connection refused rtsp://USERNAME:PASSWORD@192.168.50.117:554/h264Preview_01_main: Connection refused

Do you have any ideas or updates?

I can't understand why I can't run Viseron, this is weird. It looks like TCP on port 554 is failing connection. I don't know what else to try. Any suggestions?

roflcoopter commented 3 months ago

Is there any way to change the authentication method for the camera? My wild guess is that it uses some other protocol than basic authentication.

That is why you cant connect using rtsp://user:password@ip-address.

As long as you cant get it to work in VLC without being prompted for the credentials it wont work in Viseron

roflcoopter commented 3 months ago

Found this with a quick google where a user has a similar issue with another NVR: In the Win desktop app: "Select camera settings->network->advanced->server settings set up. Then check http or rtsp and onvif and select save."

Cant verify myself since i dont have a Reolink

delfredd commented 2 months ago

My Reolink Camera Setting is showing enables RTSP #554, ONVIF port, HTTPS, HTTP:

See below:

RTSP Enable screenshot

delfredd commented 2 months ago

Hi roflcoopter

I am still looking at the issue. I have been trying VLC to test the RTSP stream with no luck. Do you have any updates?

I found this: Debi/Ubu has dropped the live555 library, that VLC used to play RTSP. Any idea about this?

Which Linux distribution are you using for Viseron?

Also,

Am I able to use Viseron under Windows? In my case, under Windows RTSP is fine. Just curious.

Please help!

Thank you!

roflcoopter commented 2 months ago

Viseron only runs on Linux sadly. The container is based on Ubuntu, but Viseron is not using VLC so that is not a problem.

I use 4 different RTSP cameras and they work great, so RTSP support is not the problem either.

I think maybe you should try the HTTP URL instead and see if that works better.

Any errors with a config similar to this? Notice that the username/password is passed in the path so it should be omitted as separate config options.

ffmpeg:
  camera:
    camera_1: # This value has to be unique across all cameras
      name: Dogs View
      host: 192.168.50.117
      port: 80
      protocol: http
      path: /flv?port=1935&app=bcs&stream=channel0_ext.bcs&user={REOLINK_USERNAME}&password={REOLINK_PASSWORD}
      fps: 15

Not 100% sure on the config format so might error out but i think it should work

delfredd commented 2 months ago

Hi roflcoopter,

Good news:

I was able to solve the issue. The camera's password had a special character (@#), so the RTSP protocol indicated that the connection was refused. After changing the password, I can see the cameras using Viseron. "'string': 'Connection refused'}}"

Now I am going to configure the object detection and when a motion happens, make the camera trigger the recording.

Thanks for all your help and support.

delfredd commented 2 months ago

See below:

Viseron2

Thanks!

roflcoopter commented 2 months ago

Ahh how silly! Nice job.

That issue (with special characters in the password) is fixed in the v3 beta.

Closing this issue, please open a new one if you face any other issues