FFmpeg/Amcrest device error on boot

Hello all!

I recently upgraded to hass 0.87.1 and have been having a strange problem ever since. For whatever reason FFmpeg integration seems to have broken, and this is causing my amcrest component to error out as well. The video stream still displays snapshots just fine in lovelace, but clicking on the image to view full size will never load. In addition to that, I monitor SD card space, and motion detection with this camera and neither sensor shows up in the UI any more. There have been no camera configuration changes on the device, or in hass, and firewall rules / my routing tables are unchanged. The only thing that has changed since this broke is an upgrade to 0.87.1

This is the error I see on boot:

2019-02-20 14:31:29 ERROR (MainThread) [haffmpeg.core] FFmpeg fails [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/haffmpeg/core.py", line 114, in open
    stderr=stderr
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/subprocess.py", line 225, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/base_events.py", line 1191, in subprocess_exec
    bufsize, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/unix_events.py", line 191, in _make_subprocess_transport
    **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/base_subprocess.py", line 39, in __init__
    stderr=stderr, bufsize=bufsize, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/unix_events.py", line 697, in _start
    universal_newlines=False, bufsize=bufsize, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'
2019-02-20 14:31:29 WARNING (MainThread) [haffmpeg.tools] Error starting FFmpeg.
2019-02-20 14:31:30 ERROR (MainThread) [homeassistant.components.sensor] amcrest: Error on device update!
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity_platform.py", line 248, in _async_add_entity
    await entity.async_device_update(warning=False)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/entity.py", line 349, in async_device_update
    await self.hass.async_add_executor_job(self.update)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/concurrent/futures/thread.py", line 56, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/sensor/amcrest.py", line 103, in update
    sd_used = self._camera.storage_used
  File "/srv/homeassistant/lib/python3.6/site-packages/amcrest/storage.py", line 39, in storage_used
    status = [s for s in ret.split() if '.UsedBytes=' in s][0]
IndexError: list index out of range

If I try to view the full size image through the UI, I will be presented with this error:

2019-02-20 14:53:11 ERROR (MainThread) [haffmpeg.core] FFmpeg fails [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/haffmpeg/core.py", line 114, in open
    stderr=stderr
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/subprocess.py", line 225, in create_subprocess_exec
    stderr=stderr, **kwds)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/base_events.py", line 1191, in subprocess_exec
    bufsize, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/unix_events.py", line 191, in _make_subprocess_transport
    **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/base_subprocess.py", line 39, in __init__
    stderr=stderr, bufsize=bufsize, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/asyncio/unix_events.py", line 697, in _start
    universal_newlines=False, bufsize=bufsize, **kwargs)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/subprocess.py", line 709, in __init__
    restore_signals, start_new_session)
  File "/opt/rh/rh-python36/root/usr/lib64/python3.6/subprocess.py", line 1344, in _execute_child
    raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'ffmpeg': 'ffmpeg'
2019-02-20 14:53:11 WARNING (MainThread) [haffmpeg.core] FFmpeg isn't running!
2019-02-20 14:53:11 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 418, in start
    resp = await task
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_app.py", line 458, in _handle
    resp = await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_middlewares.py", line 119, in impl
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/real_ip.py", line 34, in real_ip_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/ban.py", line 67, in ban_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/auth.py", line 99, in auth_middleware
    return await handler(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/http/view.py", line 118, in handle
    result = await result
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/camera/__init__.py", line 407, in get
    return await self.handle(request, camera)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/camera/__init__.py", line 443, in handle
    return await camera.handle_async_mjpeg_stream(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/components/camera/amcrest.py", line 85, in handle_async_mjpeg_stream
    self._ffmpeg.ffmpeg_stream_content_type)
  File "/srv/homeassistant/lib/python3.6/site-packages/homeassistant/helpers/aiohttp_client.py", line 111, in async_aiohttp_proxy_stream
    data = await stream.read(buffer_size)
  File "/srv/homeassistant/lib/python3.6/site-packages/haffmpeg/core.py", line 155, in read
    return self._proc.stdout.read(count)
AttributeError: 'NoneType' object has no attribute 'stdout'
2019-02-20 14:53:11 ERROR (MainThread) [aiohttp.server] Unhandled exception
Traceback (most recent call last):
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 447, in start
    await resp.prepare(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_response.py", line 353, in prepare
    return await self._start(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_response.py", line 667, in _start
    return await super()._start(request)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/web_response.py", line 410, in _start
    await writer.write_headers(status_line, headers)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 112, in write_headers
    self._write(buf)
  File "/srv/homeassistant/lib/python3.6/site-packages/aiohttp/http_writer.py", line 67, in _write
    raise ConnectionResetError('Cannot write to closing transport')
ConnectionResetError: Cannot write to closing transport
1 Like

This would tell me that I need to install ffmpeg, but seeing that this is a new error, I am doubtful…

For extra information, my configs are as follows:
camera.yaml
- platform: amcrest

amcrest.yaml (host: is just ip of camera)

- host: !secret cam11
  username: !secret cam11_user
  password: !secret cam11_pass
  name: 'Front Drive'
  stream_source: rtsp
  resolution: low
  scan_interval: 20
  sensors:
    - motion_detector
    - sdcard

configuration.yaml (relevant parts only)

amcrest: !include amcrest.yaml
camera: !include camera.yaml

Outside of camera.yaml you should have ffmpeg support enabled in config.

In same place you define ffmpeg location(or have nothing for default location)

ffmpeg:
  ffmpeg_bin: /usr/bin/ffmpeg