core: camera stream recording getting stuck

Home Assistant release with the issue: 99.2

Operating environment (Hass.io/Docker/Windows/etc.): HASSIO running on linux mini pc

Integration: https://www.home-assistant.io/integrations/stream

Description of problem: when calling the camera.record service I get the following error: Call-service API error. Error Message: Stream already recording to /config/www/xxx.mp4

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

- platform: ffmpeg
  name: woonkamer
  input: -rtsp_transport tcp -i rtsp://192.168.0.51:8554/unicast

Additional information:

2019-10-04 00:34:49 ERROR (MainThread) [homeassistant.components.websocket_api.http.connection.140371347870992] Stream already recording to /config/www/xxxxx.mp4!
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/components/websocket_api/commands.py", line 130, in handle_call_service
    connection.context(msg),
  File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1259, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/helpers/entity_component.py", line 213, in handle_service
    self._platforms.values(), func, call, service_name, required_features
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 349, in entity_service_call
    future.result()  # pop exception if have
  File "/usr/src/homeassistant/homeassistant/helpers/service.py", line 373, in _handle_service_platform_call
    await func(entity, data)
  File "/usr/src/homeassistant/homeassistant/components/camera/__init__.py", line 712, in async_handle_record_service
    DOMAIN_STREAM, SERVICE_RECORD, data, blocking=True, context=call.context
  File "/usr/src/homeassistant/homeassistant/core.py", line 1234, in async_call
    await asyncio.shield(self._execute_service(handler, service_call))
  File "/usr/src/homeassistant/homeassistant/core.py", line 1259, in _execute_service
    await handler.func(service_call)
  File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 130, in async_record
    await async_handle_record_service(hass, call)
  File "/usr/src/homeassistant/homeassistant/components/stream/__init__.py", line 232, in async_handle_record_service
    raise HomeAssistantError(f"Stream already recording to {recorder.video_path}!")
homeassistant.exceptions.HomeAssistantError: Stream already recording to /config/www/xxxxx.mp4!

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Reactions: 5
  • Comments: 28 (3 by maintainers)

Most upvoted comments

I can confirm that the issue remains, at least in my case, in current version.

I have an automation that records 15 seconds. Since yesterday I have the error Call-service API error. Error Message: Stream already recording to /config/www/images/security/casa/video/casa_video_20200916_145343.mp4!

So the message is several hours old. There is no such file in the folder, so it seems the recording has failed and it thinks it is recording.

This is not the first time I have this error. The only way to make it work again is to reboot the system.

Out of curiosity, did any of you have a RuntimeError: dictionary changed size during iteration error message from in your logs? It could cause this, as the worker thread will stop without closing the stream outputs. If that’s the case, #38766 may fix the issue.

Would prefer to have a camera.record_stop and camera.record_start service. In that way you get more control. The default 30 sec recording can still be applicable but can be overruled by a camera.record_stop service… I also face the issue that although I programmed a duration and lookback period that the record doesn’t finish and blocks any new records until I turn off and on the automation

Still happens with Home Assistant 2022.3.5 Once the record stuck it fails with the error when you trying to record again and it says: Stream already recording to /media/camera/latest_motion_salon.mp4! Please advise what is required for the further debug.

This issue is not fixed yet