[FIXED] Ffmpeg camera works in macbook, doesn't work in hass.io

Hi,

I can’t get a ffmpeg camera (xiaomi dafang) to work on hass.io (on a PI 3 B), but the same config works on hass running on my macbook in the same network.

This is my config, which is exactly the same in both instances:

ffmpeg:

camera:
  - platform: ffmpeg
    name: camera_sala
    input: -rtsp_transport tcp -i rtsp://192.168.XX.XX:8554/unicast

This is the log entry for hass.io:

2018-07-30 00:30:12 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-rtsp_transport', 'tcp', '-i', 'rtsp://192.168.XX.XX:8554/unicast', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-f', 'image2pipe', '-']
2018-07-30 00:30:17 WARNING (MainThread) [haffmpeg.tools] Timeout reading image.

Now this is the log entries on my macbook:

2018-07-29 21:33:34 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-rtsp_transport', 'tcp', '-i', 'rtsp://192.168.XX.XX:8554/unicast', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-f', 'image2pipe', '-']
2018-07-29 21:33:35 DEBUG (MainThread) [homeassistant.components.websocket_api] WS 4422661344: Sending {'id': 16, 'type': 'result', 'success': True, 'result': {'content_type': 'image/jpeg', 'content': '/9j//gARTGF2YzU3LjEwNy4...TExMTExMWFRYXFxcWFhYWFxcXGRkZHR0dGRkZFxcZGRwcHR0gISAeHh0eISEjIyMqKigoMTEyPDxI/8QAsQAAAgMBAQEBAAAAAAAAAAAAAAEDBAIFBgcIAQEAAw

You can see the ffmpeg command is exactly the same, but it times out on the PI but works on the mac.

All other components are working fine in hass.io. I can even pan/tilt the camera using mqtt, turn the leds on/off, and enable/disable night mode.

Thanks in advance.

Is there any difference when using rtsp://user:[email protected]:8554/unicast ?

No, I just tried adding user/password to the Dafang Hacks console, works on the mac instance but doesn’t in hass.io. I just got some more log entries when home assistant restarts:

2018-07-29 22:45:50 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-rtsp_transport', 'tcp', '-i', 'rtsp://test:[email protected]:8554/unicast', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-f', 'image2pipe', '-']
2018-07-29 22:45:52 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-rtsp_transport', 'tcp', '-i', 'rtsp://test:[email protected]:8554/unicast', '-an', '-c:v', 'mjpeg', '-f', 'mpjpeg', '-']
2018-07-29 22:45:56 WARNING (MainThread) [haffmpeg.tools] Timeout reading image.
2018-07-29 22:46:00 DEBUG (MainThread) [haffmpeg.core] Start FFmpeg with ['ffmpeg', '-rtsp_transport', 'tcp', '-i', 'rtsp://test:[email protected]:8554/unicast', '-an', '-frames:v', '1', '-c:v', 'mjpeg', '-f', 'image2pipe', '-']
2018-07-29 22:46:01 WARNING (MainThread) [haffmpeg.tools] Timeout reading image.
2018-07-29 22:46:05 WARNING (MainThread) [haffmpeg.tools] Timeout reading image.
2018-07-29 22:46:07 WARNING (MainThread) [haffmpeg.core] Timeout while waiting of FFmpeg

I seem to have fixed the issue by removing most of my configuration out. Now I am going to gradually add it back and try to understand if any other configuration was impacting ffmpeg.

Did you find out what was impacting ffmpeg? I’m having the same issues …

Same here. Worked beautifully on a standalone docker image, but DAFANG RTSP streams are non-working (with the occasional random exception) on hassio :frowning:

I found out that my DAFANG RTSP h264 stream does work when I disable the MQTT functions in the camera. This is in my configuration:

camera:

  • platform: ffmpeg
    name: Dafang
    input: -rtsp_transport tcp -i rtsp://192.168.0.xxx:8554/unicast

unfortunately I am not able to control the camera this way …

EDIT:
I have it all set up and working now. The only way it worked for me was routing the MQTT messages through a seperate MQTT cloud broker en setting up a bridge connection to HA. Having MQTT and RTSP stream at the same time to my HA instance does not work …

I have never been able to get the openipc camera to work with hass.io. I get a great image from the camera if I connect to it but nothing form hass.io. I have turned off mqtt on the camera - no change.