Stream camera Home Assistant

Dear Hunterjm and others,

I kindly came to ask your help to make work the stream function of my camera in Home Assistant. I spent the last days trying to figure out how to make it work, but without success.

I’m running Hass.io in a Raspberry Pi 3B+ and using a generic / chinese camera (Guanghou - IPC, model C3-S-H3 sold as Lenovo brand). I already tested with success this camera with VLC software (still image and streaming) and I used the HTTP and RSTP adress to set it up in HA. There, my configuration.yalm is like this:

Copy to clipboard

stream: 
camera:
- platform: generic
  name: camera1
  username: XXXX
  password: YYYY
  authentication: digest
  verify_ssl: false
  still_image_url: http://192.168.0.29/snapshot.jpg?
  stream_source: rtsp://XXXX:[email protected]/ch0_0.264

Note1: The stream address above works on VLC.
Note2: My Home assistant version: 0.108.6; Frontend version: 20200407.2 - latest

I inserted a card in my lovelace with the following configuration:

Copy to clipboard

aspect_ratio: 50%
camera_image: camera.camera1
entity: camera.camera1
name: Camera
type: picture-entity

The static image of the camera appears in this card, but when I click on it to start the stream function, it opens a media player window but does not play the video.
I tried in a lot different ways but never the streaming function works…

In my error file log there is only this 2 lines:

Copy to clipboard

2020-04-22 22:27:52 ERROR (stream_worker) [homeassistant.components.stream.worker] Error demuxing stream: No dts in packet
2020-04-22 22:27:59 ERROR (SyncWorker_3) [homeassistant.components.generic.camera] Error getting new camera image from camera1: HTTPConnectionPool(host='192.168.0.29', port=80): Read timed out.

I would be very grateful if you can help me with this matter…

What video encoding mode is the camera configured for? The stream component, AFAIK, does not support MJPEG. You need to configure your camera for H.264 (or some variant like H.264H.)

Hi there! My camera is using H.264!

Hi Friend, any additional idea? Thanks a lot!

The only thing that comes to mind is HA running on your RPi is not able to reach your camera using those URLs, since both the stream component, and the generic camera component, can’t seem to communicate with it (based on the error messages.)

Can you run a curl command from the RPi, e.g., via the ssh add-on? If so, try:

curl -v --digest -u XXXX:YYYY http://192.168.0.29/snapshot.jpg?

Hello Phil!

I made as your request and got the following return:

~ $ curl -v --digest -u XXXX:YYYY http://192.168.0.101/snapshot.jpg?

* Trying 192.168.0.101:80...

* TCP_NODELAY set

* Connected to 192.168.0.101 (192.168.0.101) port 80 (#0)

* Server auth using Digest with user 'XXXX'

> GET /snapshot.jpg? HTTP/1.1

> Host: 192.168.0.101

> User-Agent: curl/7.67.0

> Accept: */*

>

* Mark bundle as not supporting multiuse

< HTTP/1.1 200 OK

< Content-Length: 19083

< Content-Type: application/octet-stream

<

Warning: Binary output can mess up your terminal. Use "--output -" to tell

Warning: curl to output it to your terminal anyway, or consider "--output

Warning: <FILE>" to save to a file.

* Failed writing body (0 != 1348)

* Closing connection 0

~ $

Note: Don’t worry about camera IP address, I had to change it.

Any possible support?