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

ffmpeg timeout but it works from cmdline #354

Closed pierg75 closed 2 years ago

pierg75 commented 2 years ago

I wanted to try viseron and when I configured a couple of cameras, I always get:

[2022-06-20 13:15:19] [ERROR   ] [viseron.camera.stream.front_door] - Retrying None in 30.0 seconds as it raised FFprobeTimeout: FFprobe command ffprobe -hide_banner -loglevel debug -print_format json -show_error -show_streams rtsp://admin
:XXXXXX@192.168.1.250:554/h264_stream timed out after 105s.
[2022-06-20 13:15:19] [ERROR   ] [viseron.camera.stream.indoor] - Retrying None in 30.0 seconds as it raised FFprobeTimeout: FFprobe command ffprobe -hide_banner -loglevel debug -print_format json -show_error -show_streams rtsp://admin:YYYYY@192.168.1.251:554/h264_stream timed out after 105s.

Howver, if I check the ffmpeg debug logs it says:

[2022-06-20 13:15:49] [ERROR   ] [viseron.camera.stream.front_door] - [tcp @ 0x560d6e5efbc0] Successfully connected to 192.168.1.250 port 554
[2022-06-20 13:15:49] [ERROR   ] [viseron.camera.stream.indoor] - [tcp @ 0x55692616cbc0] Successfully connected to 192.168.1.251 port 554

And if I try manually from the same host where the container is run, it seems to work normally:

~% ffprobe -hide_banner -loglevel error -print_format json -show_error -show_streams rtsp://admin:YYYYY@192.168.1.251:554/h264_stream
{
    "streams": [
        {
            "index": 0,
            "codec_name": "h264",
            "codec_long_name": "H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10",
            "profile": "Main",
            "codec_type": "video",
            "codec_tag_string": "[0][0][0][0]",
            "codec_tag": "0x0000",
            "width": 1920,
            "height": 1080,
            "coded_width": 1920,
            "coded_height": 1080,
            "closed_captions": 0,
            "film_grain": 0,
            "has_b_frames": 0,
            "pix_fmt": "yuvj420p",
            "level": 41,
            "color_range": "pc",
            "color_space": "bt709",
            "color_transfer": "bt709",
            "color_primaries": "bt709",
            "chroma_location": "left",
            "field_order": "progressive",
            ...
roflcoopter commented 2 years ago

Could you show the full debug logs from Viseron startup?

pierg75 commented 2 years ago

I actually got it working (at least the cameras) by using --network=host on the podman line (sorry forgot to say I'm using podman and not docker). I really need to review the networking model for these containers. I guess we can close this, sorry for the noise.

roflcoopter commented 2 years ago

I actually got it working (at least the cameras) by using --network=host on the podman line (sorry forgot to say I'm using podman and not docker). I really need to review the networking model for these containers. I guess we can close this, sorry for the noise.

Ahh i see, great you got it working! No worries, let me know if you face any other issues.

sagargp commented 1 year ago

I'm having this issue also, and I don't want to use host mode networking. I am able to ping the camera from inside the container, but ffprobe hangs forever.

root@f942ccf5e773:/src# ping -c1 10.0.0.224
PING 10.0.0.224 (10.0.0.224): 56 data bytes
64 bytes from 10.0.0.224: icmp_seq=0 ttl=63 time=2.453 ms
--- 10.0.0.224 ping statistics ---
1 packets transmitted, 1 packets received, 0% packet loss
round-trip min/avg/max/stddev = 2.453/2.453/2.453/0.000 ms

Seems like docker isn't forwarding ports properly somehow? This works fine with my Frigate container, incidentally.

roflcoopter commented 1 year ago

Could you show your config and debug logs please?

sagargp commented 1 year ago

Yes, here is my docker-compose config:

    viseron:
        image: roflcoopter/amd64-cuda-viseron:latest
        volumes:
            - ./viseron/recordings:/recordings
            - ./viseron/config:/config
            - /etc/localtime:/etc/localtime:ro
        ports:
            - 8888:8888
        runtime: nvidia
        privileged: true
        devices:
          - /dev/bus/usb:/dev/bus/usb
        environment:
            PUID: ${UID}
            PGID: ${GID}

Viseron camera config:

ffmpeg:
  camera:
    cat_tree:
      name: Cat Tree
      host: 10.0.0.224
      port: 554
      path: /live
      username: admin
      password: password
      stream_format: rtsp
      protocol: rtsp

And a snippet of the logs from the Viseron container:

docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.core] - -------------------------------------------
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.core] - Initializing Viseron
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setting up component data_stream
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setup of component data_stream took 0.0 seconds
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setting up component webserver
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setup of component webserver took 0.0 seconds
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setting up component mog2
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setting up component ffmpeg
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setting up component darknet
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setting up component nvr
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setup of component nvr took 0.0 seconds
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setup of component mog2 took 0.0 seconds
docker-viseron-1  | [2023-05-06 11:09:37] [INFO    ] [viseron.components] - Setup of component ffmpeg took 0.0 seconds
docker-viseron-1  | [2023-05-06 11:09:39] [INFO    ] [viseron.components] - Setup of component darknet took 2.0 seconds
docker-viseron-1  | [2023-05-06 11:09:39] [INFO    ] [viseron.components] - Setting up domain camera for component ffmpeg with identifier cat_tree
docker-viseron-1  | [2023-05-06 11:09:39] [INFO    ] [viseron.components] - Setting up domain motion_detector for component mog2 with identifier cat_tree
docker-viseron-1  | [2023-05-06 11:09:39] [INFO    ] [viseron.components] - Setting up domain object_detector for component darknet with identifier cat_tree
docker-viseron-1  | [2023-05-06 11:09:39] [INFO    ] [viseron.components] - Setting up domain nvr for component nvr with identifier cat_tree
docker-viseron-1  | [2023-05-06 11:09:54] [ERROR   ] [viseron.components.ffmpeg.stream.cat_tree] - Retrying None in 2.0 seconds as it raised FFprobeTimeout: FFprobe command timed out after 15s.

---snip---

docker-viseron-1  | [2023-05-05 21:53:32] [ERROR   ] [viseron.components.ffmpeg.stream.cat_tree] - Retrying None in 30.0 seconds as it raised FFprobeTimeout: FFprobe command timed out after 75s.
docker-viseron-1  | [2023-05-05 21:53:47] [WARNING ] [viseron.components] - Domain nvr for component nvr with identifier cat_tree is still waiting for dependencies: ['domain: camera, identifier: cat_tree', 'domain: object_detector, identifier: cat_tree', 'domain: motion_detector, identifier: cat_tree']
docker-viseron-1  | [2023-05-05 21:53:47] [WARNING ] [viseron.components] - Domain object_detector for component darknet with identifier cat_tree is still waiting for dependencies: ['domain: camera, identifier: cat_tree', 'domain: motion_detector, identifier: cat_tree']
docker-viseron-1  | [2023-05-05 21:53:47] [WARNING ] [viseron.components] - Domain motion_detector for component mog2 with identifier cat_tree is still waiting for dependencies: ['domain: camera, identifier: cat_tree']
docker-viseron-1  | [2023-05-05 21:54:26] [ERROR   ] [viseron.components] - Uncaught exception setting up domain camera for component ffmpeg: Could not get needed stream information. Missing at least one of width, height or fps. Width: 0 Height: 0 FPS: 0
docker-viseron-1  | Traceback (most recent call last):
docker-viseron-1  |   File "/src/viseron/components/__init__.py", line 407, in setup_domain
docker-viseron-1  |     result = domain_module.setup(
docker-viseron-1  |   File "/src/viseron/components/ffmpeg/camera.py", line 295, in setup
docker-viseron-1  |     Camera(vis, config[identifier], identifier)
docker-viseron-1  |   File "/src/viseron/components/ffmpeg/camera.py", line 310, in __init__
docker-viseron-1  |     self.stream = Stream(config, self, identifier)
docker-viseron-1  |   File "/src/viseron/components/ffmpeg/stream.py", line 142, in __init__
docker-viseron-1  |     raise StreamInformationError(self.width, self.height, self.fps)
docker-viseron-1  | viseron.exceptions.StreamInformationError: Could not get needed stream information. Missing at least one of width, height or fps. Width: 0 Height: 0 FPS: 0

Let me know if you need more log output.

sagargp commented 1 year ago

I resolved this (sort of) by running ffprobe from the host and manually specifying the needed arguments. So the streams work now. Unclear why ffprobe wasn't working.

roflcoopter commented 1 year ago

Great that you got it sorted. I don't know why ffprobe is acting up, might need to look at alternative ways to get stream information