Generic IP Camera sp32cam Invalid data

After a painless setup of esp32cam using Arduino IDE the camera web server is all normal and I can start a stream, get a still, etc, etc.

However on trying to add to my 0.91.0 install of HA (on a QNAP Docker) with config set as a Generic IP Camera I added this to my config:

camera:
  - platform: generic
    name: esp32Cam2
    stream_source: http://192.168.1.189:81/stream
    still_image_url: http://192.168.1.189:81/

And on restarting I get the below

2019-04-07 00:30:46 INFO (MainThread) [homeassistant.components.stream] Started stream: http://X.X.X.X:81/stream                                                                                                                                                              
Exception in thread stream_worker:                                                                                                                                                                                                                                                  
Traceback (most recent call last):                                                                                                                                                                                                                                                  
  File "/usr/local/lib/python3.7/threading.py", line 917, in _bootstrap_inner                                                                                                                                                                                                       
    self.run()                                                                                                                                                                                                                                                                      
  File "/usr/local/lib/python3.7/threading.py", line 865, in run                                                                                                                                                                                                                    
    self._target(*self._args, **self._kwargs)                                                                                                                                                                                                                                       
  File "/usr/src/app/homeassistant/components/stream/worker.py", line 53, in stream_worker                                                                                                                                                                                          
    container = av.open(stream.source, options=stream.options)                                                                                                                                                                                                                      
  File "av/container/core.pyx", line 275, in av.container.core.open                                                                                                                                                                                                                 
  File "av/container/core.pyx", line 227, in av.container.core.Container.__cinit__                                                                                                                                                                                                  
  File "av/container/core.pyx", line 129, in av.container.core.ContainerProxy.__init__                                                                                                                                                                                              
  File "av/container/core.pyx", line 195, in av.container.core.ContainerProxy.err_check                                                                                                                                                                                             
  File "av/utils.pyx", line 105, in av.utils.err_check                                                                                                                                                                                                                              
av.AVError: [Errno 1094995529] Invalid data found when processing input: 'http://X.X.X.X:81/stream'

The still image and stream never appear.
Has anyone else had a problem with this?
Am I using the right URL’s?

PS: /dev/state shows the entity ID like this:

Entity: camera.esp32cam2

State: idle

Attributes: 
access_token: dea245f6e549b38dbf8b5e7bb63080cc2caec1583ca1201334a6bf233e0ebca3

friendly_name: esp32Cam2
 
entity_picture: /api/camera_proxy/camera.esp32cam2?

token=dea245f6e549b38dbf8b5e7bb63080cc2caec1583ca1201334a6bf233e0ebca3 

supported_features: 2

Cheers!

Making some progress here by trying to get another IP Camera connected. Its a very old Techview (Jaycar) IP camera that still works via its web interface.

I have tried in the past to set it up using this component but failed.

At present have the config setup as:

  - platform: generic
    name: techview
    stream_source: rtsp://myUsername:[email protected]:8023/11
    still_image_url: http://X.X.X.X:8023/snapshot?
    username: myUsername
    password: myPassword 

However nothing works and the errors say:

2019-04-07 12:47:02 INFO (MainThread) [homeassistant.components.stream] Started stream: rtsp://myUsername:[email protected]:8023/11                                                                                                                                                 
2019-04-07 12:47:07 ERROR (stream_worker) [homeassistant.components.stream.worker] Error demuxing stream: No dts in packet                                                                                                                                                          
2019-04-07 12:47:07 INFO (MainThread) [homeassistant.components.stream] Stopped stream: rtsp://myUsername:[email protected]:8023/11                                                                                                                                                 
2019-04-07 12:47:07 ERROR (MainThread) [aiohttp.server] Error handling request                                                                                                                                                                                                      
Traceback (most recent call last):                                                                                                                                                                                                                                                  
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start                                                                                                                                                                                         
    resp = await task                                                                                                                                                                                                                                                               
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle                                                                                                                                                                                            
    resp = await handler(request)                                                                                                                                                                                                                                                   
  File "/usr/local/lib/python3.7/site-packages/aiohttp/web_middlewares.py", line 119, in impl                                                                                                                                                                                       
    return await handler(request)                                                                                                                                                                                                                                                   
  File "/usr/src/app/homeassistant/components/http/real_ip.py", line 33, in real_ip_middleware                                                                                                                                                                                      
    return await handler(request)                                                                                                                                                                                                                                                   
  File "/usr/src/app/homeassistant/components/http/ban.py", line 68, in ban_middleware                                                                                                                                                                                              
    return await handler(request)                                                                                                                                                                                                                                                   
  File "/usr/src/app/homeassistant/components/http/auth.py", line 216, in auth_middleware                                                                                                                                                                                           
    return await handler(request)                                                                                                                                                                                                                                                   
  File "/usr/src/app/homeassistant/components/http/view.py", line 114, in handle                                                                                                                                                                                                    
    result = await result                                                                                                                                                                                                                                                           
  File "/usr/src/app/homeassistant/components/stream/core.py", line 176, in get                                                                                                                                                                                                     
    return await self.handle(request, stream, sequence)                                                                                                                                                                                                                             
  File "/usr/src/app/homeassistant/components/stream/hls.py", line 43, in handle                                                                                                                                                                                                    
    track, utcnow()).encode("utf-8"), headers=headers)                                                                                                                                                                                                                              
  File "/usr/src/app/homeassistant/components/stream/hls.py", line 103, in render                                                                                                                                                                                                   
    self.render_preamble(track) +                                                                                                                                                                                                                                                   
  File "/usr/src/app/homeassistant/components/stream/hls.py", line 77, in render_preamble                                                                                                                                                                                           
    "#EXT-X-TARGETDURATION:{}".format(track.target_duration),                                                                                                                                                                                                                       
  File "/usr/src/app/homeassistant/components/stream/core.py", line 83, in target_duration                                                                                                                                                                                          
    return round(sum(durations) // len(self._segments)) or 1                                                                                                                                                                                                                        
ZeroDivisionError: integer division or modulo by zero

I then found that if I forget the stream and just try to get the still image sorted I was able to display the still image AND the stream by using this config below:

As soon as I commented out the stream URL and restart HA I had a live stream working which is a surprise but I’m very happy with that in any case.

I think I will try the same deal with the esp32cam problem above? IE: get the still image working and leave out the stream URL?

I’ll report back as I get onto that.

More progress…

My current Camera config:

camera:
  - platform: generic
    name: esp32Cam2
    still_image_url: http://X.X.X.X/capture?

  - platform: generic
    name: techview
    still_image_url: http://X.X.X.X:8023/snapshot?
    username: myUsername
    password: myPassword

This is currently working for both cameras even though I believe (from what information I have found) the esp32cam is an mjpeg stream.

Can anyone confirm that please?

Cheers!