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
72.73k stars 30.46k forks source link

camera.record duration issues #30025

Closed pszewello closed 4 years ago

pszewello commented 4 years ago

Home Assistant release with the issue:

0.103.0

Last working Home Assistant release (if known): unkown

Operating environment (Hass.io/Docker/Windows/etc.):

Hass.io on RPI3b+ Integration:

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

Description of problem: When calling the camera.record service with duration, the mp4 is created but duration is not correct and not consistent. Calling the service with 30 sec duration, produces 1s video, sometimes 3seconds, sometimes 7... expecting a 30sec one.

Problem-relevant configuration.yaml entries and (fill out even if it seems unimportant):

stream:
ffmpeg:
camera: 
  - platform: ffmpeg
    name: yi_living_room
    input: !secret camera_yi_living_room_rstp

Traceback (if applicable):

Additional information: Using AppDeamon 4.1 automations, with ffmpeg cameras and hd rstp stream. self.call_service("camera/record", entity_id=camera, filename=video.file_path, duration=30)

IsaTTeN commented 4 years ago

Hi, I have the same problem, it doesn´t matter if I choose the platform ffmpeg or generic, the duration showed is less than expected.

Also if I try to send the video to Telegram I got an error in the Telegram Bot becasue the file have some problem for this reason. If I try to send another mp4 it works good

Thanks @frenck for your support!!

rwarner commented 4 years ago

Same situation with Unifi cameras on RTSP stream. Random amounts of unreliable time regardless of if I put in the "lookback" value or not.

rwarner commented 4 years ago

Haven't upgraded beyond 1.0.3, but am hesitant due to the current stable state of my HA besides this problem.

Is there a way I can provide more information to potentially having this resolved / investigated? I'm curious to start looking into the code to see if this can be resolved, just not sure where to start.

Sloth-on-meth commented 4 years ago

Bump - this issue is causing a slew of errors in my setup. Anyone know a workaround?

SaturnusDJ commented 4 years ago

Similar issues. (0.108.3).

I would like to (sometimes) record for hours long. Knowing how video files always have problems I decided to split by 15 minutes.

- alias: Record
  trigger:
  - platform: time_pattern
    minutes: "/15"
  action:
  - service: camera.record
    data_template:
      entity_id: camera.camera
      filename: '/config/www/camera_{{ now().strftime("%Y-%m-%d_%H-%M-%S") }}.mp4'
      duration: 900

Observations:

Rikkie80 commented 4 years ago
  • Sometimes the recording does not stop or is not marked as stopped (?) so that future recording becomes impossible. Stream already recording to ...

Recognise this as well. Would be nice to have an indication of the state of service.record to block an automation to start a new record before the other is finished and the ability to stop it with an automation or input_boolean.

I tried to fix things with delays etc. but still run into the issue after a couple of recordings.

Automation:

- alias: motion detection oprit
  trigger:
    - platform: state
      entity_id: binary_sensor.motion_sensor_buiten_motion
      to: 'on'
  condition:
    - condition: state
      entity_id: input_boolean.record_oprit
      state: 'off'
  action:
    - service: script.turn_on
      entity_id: script.oprit_movie

Script:

oprit_movie:
  alias: Film van oprit na motion trigger
  icon: mdi:cctv
  sequence:
    - service: input_boolean.turn_on
      entity_id: input_boolean.record_oprit
    - service: camera.record
      data_template:
        entity_id: camera.oprit
        filename: 'www/video/oprit_{{ now().strftime("%Y%m%d-%H%M%S") }}.mp4'
        lookback: 15
    - delay:
        seconds: 60
    - service: input_boolean.turn_off
      entity_id: input_boolean.record_oprit
SaturnusDJ commented 4 years ago

I also tried delay. It is totally unpredictable how much delay is needed and it will make you miss records.

Seems like this stream/camera/record feature is hastily dropped into HA without proper testing. When I have more time I will look at dedicated camera software, hopefully able to be controlled by HA automations (via MQTT maybe).

stale[bot] commented 4 years 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 now has been marked as stale and will be closed if no further activity occurs. Thank you for your contributions.