WebThingsIO / onvif-adapter

ONVIF Profile S video camera adapter
Mozilla Public License 2.0
10 stars 6 forks source link

Support for Revotech I6032 #13

Closed tssk closed 5 years ago

tssk commented 5 years ago

Hello,

I was amazed when I found this Mozilla IOT Gateway Add-on for cameras! Please consider this as a feature request/request for help/sharing of experience.

I am trying to get this working with "cheap chinese HD IP camera". Based on this https://www.jpavlik.cz/aliexpress-ip-cameras-review/ blog post I decided to try Revotech I6032, specifically I6032W-V200-POE (white, non-sony chip, PoE).

I am using Mozilla IOT Gateway 0.8.1 installed on Debian 9 in virtualbox according to official procedure on github. Then I installed ffmpeg from debian package. And added ONVIF Add-on and it correctly autodetected camera IP (192.168.1.206). I had to set password for the default admin user because the Add-on does not seem to allow empty password. After setting the password Gateway was able to detect and add Video Camera Thing.

Screenshot works ok. Stream does not work.

2019-07-09 09:13:40.149 INFO   : Successfully created new thing kamera
2019-07-09 09:13:42.991 ERROR  : Thing was not added
2019-07-09 09:13:42.992 ERROR  : addNewThing cancelled
2019-07-09 09:13:42.996 INFO   : thing-url: Adapter: ThingURLAdapter id thing-url-adapter pairing cancelled
2019-07-09 09:14:21.859 INFO   : onvif: Unhandled Rejection
2019-07-09 09:14:21.862 ERROR  : onvif: { Error: socket hang up
2019-07-09 09:14:21.863 ERROR  : onvif:     at createHangUpError (_http_client.js:342:15)
2019-07-09 09:14:21.864 ERROR  : onvif:     at Socket.socketOnEnd (_http_client.js:437:23)
2019-07-09 09:14:21.865 ERROR  : onvif:     at emitNone (events.js:111:20)
2019-07-09 09:14:21.884 ERROR  : onvif:     at Socket.emit (events.js:208:7)
2019-07-09 09:14:21.885 ERROR  : onvif:     at endReadableNT (_stream_readable.js:1064:12)
2019-07-09 09:14:21.887 ERROR  : onvif:     at _combinedTickCallback (internal/process/next_tick.js:139:11)
2019-07-09 09:14:21.889 ERROR  : onvif:     at process._tickCallback (internal/process/next_tick.js:181:9) code: 'ECONNRESET' }
2019-07-09 09:16:11.535 INFO   : onvif: Unhandled Rejection
2019-07-09 09:16:11.537 ERROR  : onvif: { Error: connect ECONNREFUSED 192.168.1.206:80
2019-07-09 09:16:11.541 ERROR  : onvif:     at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1191:14)
2019-07-09 09:16:11.547 ERROR  : onvif:   errno: 'ECONNREFUSED',
2019-07-09 09:16:11.548 ERROR  : onvif:   code: 'ECONNREFUSED',
2019-07-09 09:16:11.549 ERROR  : onvif:   syscall: 'connect',
2019-07-09 09:16:11.555 ERROR  : onvif:   address: '192.168.1.206',
2019-07-09 09:16:11.556 ERROR  : onvif:   port: 80 }

I can view the lowres stream manually using $ ffplay rtsp://admin:12345@192.168.1.206:5544/live1.264 (hires should be /live0.264 ) so I guess adding some correct parameters in lib/onvif-device.js should do the trick?

Maybe more generally allow manual configuration for stream url to support more cameras?

I would like to try to add support myself but I will sure need some help/advice where to start.

Thanks,

Tomas

tssk commented 5 years ago

Hardcoding camera live stream URL in lib/onvif-device.js by changing line 244

from: '-i', this.streamUrl.toString(), to: '-i', 'rtsp://admin:12345@192.168.1.206:5544/live1.264',

(and updating SHA256 cheksum for the lib/onvif-device.js file )

makes it work like a charm.

So where does profile.StreamUri.Uri come from? (I am sorry I am JavaScript illiterate.)

mrstegeman commented 5 years ago

In lib/onvif-device.js, can you change the DEBUG flag at the top to be true? After doing so, it will dump the streaming profile to the log. The URI is part of that profile.

tssk commented 5 years ago

Oh, thanks!

2019-07-09 18:47:20.789 INFO   : onvif:   "StreamUri": {
2019-07-09 18:47:20.790 INFO   : onvif:     "Uri": "rtsp://192.168.1.206:5544/live0.264",
2019-07-09 18:47:20.791 INFO   : onvif:     "InvalidAfterConnect": "false",
2019-07-09 18:47:20.792 INFO   : onvif:     "InvalidAfterReboot": "false",
2019-07-09 18:47:20.793 INFO   : onvif:     "Timeout": "PT10S"
2019-07-09 18:47:20.794 INFO   : onvif:   },

It looks correct... So the problem must be somewhere in the ffmpeg processing I guess. I will investigate that thanks!

mrstegeman commented 5 years ago

If you reset the URL back to the original this.streamUrl.toString(), you can check the output of ps -ef to see the full ffmpeg command that's running.

tssk commented 5 years ago

So it seems the problem is that the camera default settings of hi-resolution/definition stream is producing "invalid VUI" ( source https://superuser.com/a/1421470 ). Changing the hires stream resolution setting from 1920x1080 to 1280x720 makes it work ok. ( Other option is to patch ffmpeg. )

So much for "cheap chinese camera"... :)

To sum up - to get the camera working:

Thanks for your time @mrstegeman !

Tomas

mrstegeman commented 5 years ago

Great! Glad it's working for you.