home-assistant / core

:house_with_garden: Open source home automation that puts local control and privacy first.
https://www.home-assistant.io
Apache License 2.0
73.56k stars 30.74k forks source link

None value for Generic cam using Hik vision #95137

Closed eerison closed 10 months ago

eerison commented 1 year ago

The problem

I'm trying to integrate HIK vision using Generic camera, But it's complaining about dimensions not set.

I saw that it's failing here: https://github.com/home-assistant/core/blob/dev/homeassistant/components/stream/worker.py#L611

But I'm not sure why this variable (first_keyframe) is none.

What version of Home Assistant Core has the issue?

core

What was the last working version of Home Assistant Core?

No response

What type of installation are you running?

Home Assistant Core

Integration causing the issue

HIK vision

Link to integration documentation on our website

https://www.home-assistant.io/integrations/generic/

Diagnostics information

No response

Example YAML snippet

stream:
  ll_hls: true
  part_duration: 1
  segment_duration: 6
camera:
  - platform: generic
    still_image_url: http://dvr_ip/ISAPI/Streaming/channels/101/picture
    name: Garagem
    stream_source: rtsp://user_api:pass@dvr_ip:554/Streaming/Channels/101/
    username: !secret dvr_auth_user
    password: !secret dvr_auth_password
    verify_ssl: false
    authentication: basic

Anything in the logs that might be useful for us?

| Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
homeassistant    |     self.run()
homeassistant    |   File "/usr/local/lib/python3.11/threading.py", line 975, in run
homeassistant    |     self._target(*self._args, **self._kwargs)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 424, in _run_worker
homeassistant    |     stream_worker(
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 611, in stream_worker
homeassistant    |     muxer.mux_packet(first_keyframe)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 264, in mux_packet
homeassistant    |     self._av_output.mux(packet)
homeassistant    |   File "av/container/output.pyx", line 218, in av.container.output.OutputContainer.mux
homeassistant    |   File "av/container/output.pyx", line 224, in av.container.output.OutputContainer.mux_one
homeassistant    |   File "av/container/output.pyx", line 190, in av.container.output.OutputContainer.start_encoding
homeassistant    |   File "av/container/core.pyx", line 290, in av.container.core.Container.err_check
homeassistant    |   File "av/error.pyx", line 336, in av.error.err_check
homeassistant    | av.error.ValueError: [Errno 22] Invalid argument: '<none>'; last error log: [mp4] dimensions not set

Additional information

Note 1: he users that I'm testing has full access

Note 2: I tried to add a debug on top of line 611, But it didn't show in terminal logs :/ , should I do something else to my changes reflects in my environment? or is there other way to debug?

my try

    # Mux the first keyframe, then proceed through the rest of the packets
+    _LOGGER.debug("My log test:", {"keyframe": first_keyframe})
    muxer.mux_packet(first_keyframe)
home-assistant[bot] commented 1 year ago

Hey there @davet2001, mind taking a look at this issue as it has been labeled with an integration (generic) you are listed as a code owner for? Thanks!

Code owner commands Code owners of `generic` can trigger bot actions by commenting: - `@home-assistant close` Closes the issue. - `@home-assistant rename Awesome new title` Renames the issue. - `@home-assistant reopen` Reopen the issue. - `@home-assistant unassign generic` Removes the current integration label and assignees on the issue, add the integration domain after the command.

(message by CodeOwnersMention)


generic documentation generic source (message by IssueLinks)

davet2001 commented 1 year ago

Hi @eerison, setup via YAML is not the preferred method. Please can you try to set it up via the UI? I think you are likely to get the same error, but you can export the diagnostics to help find the root cause.

eerison commented 1 year ago

Hi @davet2001 Thank you for replay.

I tested via UI, But I'm getting the same issue

homeassistant    | 2023-06-25 04:44:57.821 ERROR (stream_worker) [root] Uncaught thread exception
homeassistant    | Traceback (most recent call last):
homeassistant    |   File "/usr/local/lib/python3.11/threading.py", line 1038, in _bootstrap_inner
homeassistant    |     self.run()
homeassistant    |   File "/usr/local/lib/python3.11/threading.py", line 975, in run
homeassistant    |     self._target(*self._args, **self._kwargs)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 424, in _run_worker
homeassistant    |     stream_worker(
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 611, in stream_worker
homeassistant    |     muxer.mux_packet(first_keyframe)
homeassistant    |   File "/usr/src/homeassistant/homeassistant/components/stream/worker.py", line 264, in mux_packet
homeassistant    |     self._av_output.mux(packet)
homeassistant    |   File "av/container/output.pyx", line 218, in av.container.output.OutputContainer.mux
homeassistant    |   File "av/container/output.pyx", line 224, in av.container.output.OutputContainer.mux_one
homeassistant    |   File "av/container/output.pyx", line 190, in av.container.output.OutputContainer.start_encoding
homeassistant    |   File "av/container/core.pyx", line 290, in av.container.core.Container.err_check
homeassistant    |   File "av/error.pyx", line 336, in av.error.err_check
homeassistant    | av.error.ValueError: [Errno 22] Invalid argument: '<none>'; last error log: [mp4] dimensions not set

diagnostic

{
  "home_assistant": {
    "installation_type": "Home Assistant Container",
    "version": "2023.6.2",
    "dev": false,
    "hassio": false,
    "virtualenv": false,
    "python_version": "3.11.4",
    "docker": true,
    "arch": "aarch64",
    "timezone": "America/Fortaleza",
    "os_name": "Linux",
    "os_version": "4.4.190-1233-rockchip-ayufan-gd3f1be0ed310",
    "run_as_root": true
  },
  "custom_components": {},
  "integration_manifest": {
    "domain": "generic",
    "name": "Generic Camera",
    "codeowners": [
      "@davet2001"
    ],
    "config_flow": true,
    "dependencies": [
      "http"
    ],
    "documentation": "https://www.home-assistant.io/integrations/generic",
    "iot_class": "local_push",
    "requirements": [
      "ha-av==10.1.0",
      "pillow==9.5.0"
    ],
    "is_built_in": true
  },
  "data": {
    "title": "Garagem",
    "data": {},
    "options": {
      "name": "Garagem",
      "still_image_url": "http://pai.dvr/****",
      "stream_source": "rtsp://****:****@pai.dvr:554/****",
      "authentication": "basic",
      "username": "**REDACTED**",
      "password": "**REDACTED**",
      "limit_refetch_to_url_change": false,
      "content_type": "image/jpeg",
      "framerate": 2,
      "verify_ssl": false
    }
  }
}
issue-triage-workflows[bot] commented 1 year ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

davet2001 commented 1 year ago

This looks like something with the underlying av library.

@eerison please can you confirm that this is still happening?

Could be something that @uvjustin or @allenporter might have a comment on.

uvjustin commented 1 year ago

Thanks @davet2001 . This error message popped up in a couple of issues previously but I wasn't able to replicate it. Since it's happening with a hikvision camera (they usually do a decent job with standards and their cameras play well with FFmpeg), I'll try to dig deeper to see what's going on. I suspect it might be due to these packets missing some metadata for whatever reason.

issue-triage-workflows[bot] commented 10 months ago

There hasn't been any activity on this issue recently. Due to the high number of incoming GitHub notifications, we have to clean some of the old issues, as many of them have already been resolved with the latest updates. Please make sure to update to the latest Home Assistant version and check if that solves the issue. Let us know if that works for you by adding a comment 👍 This issue has now been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.

eerison commented 10 months ago

Hello guys I didn't try again.

But as I am using go2rtc, in case it doesn't work, I guess I should handle this there.

But if I also have some positive news I will post here.

But thank you guys for your support ❤️