Amcrest/Dahua Camera Plugin streaming and PTZ for openLuup/ALTUI
-
Ok, I think I have now a pretty good idea of what happened. It would be helpful if you could look at your logs to find out what the error is though.
The issue seems to be that my installation of openLuup is not quite "vanilla" as I have made a few minor modifications to it and am also running it on LuaJIT along with some additional libraries instead of the standard Lua5.1 interpreter. I will make a minor edit to try to fix it.
Please try it and report back with what error you see in the logs if any.You can look into the openLuup section of the forum to see what changes I made to my openLuup installation. I basically decreased the CPU load by >75%
https://smarthome.community/topic/151/rapidjson-instead-of-cjson-and-dkjson
https://smarthome.community/topic/179/luajitOnly change is to the L_Amcrest.lua file so you can just replace that file in your installation and reload.
-
Ok, I think I have now a pretty good idea of what happened. It would be helpful if you could look at your logs to find out what the error is though.
The issue seems to be that my installation of openLuup is not quite "vanilla" as I have made a few minor modifications to it and am also running it on LuaJIT along with some additional libraries instead of the standard Lua5.1 interpreter. I will make a minor edit to try to fix it.
Please try it and report back with what error you see in the logs if any.You can look into the openLuup section of the forum to see what changes I made to my openLuup installation. I basically decreased the CPU load by >75%
https://smarthome.community/topic/151/rapidjson-instead-of-cjson-and-dkjson
https://smarthome.community/topic/179/luajitOnly change is to the L_Amcrest.lua file so you can just replace that file in your installation and reload.
-
@rafale77 said in Amcrest/Dahua Camera Plugin streaming and PTZ for openLuup/ALTUI:
I basically decreased the CPU load by >75%
...although, it has to be said, from a pretty small starting level anyway?
-
Ok, I think I have now a pretty good idea of what happened. It would be helpful if you could look at your logs to find out what the error is though.
The issue seems to be that my installation of openLuup is not quite "vanilla" as I have made a few minor modifications to it and am also running it on LuaJIT along with some additional libraries instead of the standard Lua5.1 interpreter. I will make a minor edit to try to fix it.
Please try it and report back with what error you see in the logs if any.You can look into the openLuup section of the forum to see what changes I made to my openLuup installation. I basically decreased the CPU load by >75%
https://smarthome.community/topic/151/rapidjson-instead-of-cjson-and-dkjson
https://smarthome.community/topic/179/luajitOnly change is to the L_Amcrest.lua file so you can just replace that file in your installation and reload.
-
Ok, we are a step further. All variables are there now. Firstly, there is a small error in the DirectStreamingURL though. The brackets should not be there.
I have removed them, but still no image.
This is the only thing I get in the log:
2020-11-22 09:56:05.011 luup.variable_set:: 93.urn:micasaverde-com:serviceId:HaDevice1.CommFailureTime was: 0 now: 0 #hooks:0 2020-11-22 09:56:05.011 openLuup.scheduler:: [93] Lobo device startup completed: status=true, msg=Ready, name=Lobo 2020-11-22 09:56:05.011 openLuup.scheduler:: [297] Amcrest Dahua device startup 2020-11-22 09:56:05.011 luup.set_failure:: status = false 2020-11-22 09:56:05.011 luup.variable_set:: 297.urn:micasaverde-com:serviceId:HaDevice1.CommFailure was: false now: false #hooks:0 2020-11-22 09:56:05.011 luup.variable_set:: 297.urn:micasaverde-com:serviceId:HaDevice1.CommFailureTime was: 1606035145 now: 1606035365 #hooks:0 2020-11-22 09:56:05.011 luup.variable_set:: 297.urn:micasaverde-com:serviceId:HaDevice1.Commands was: camera_full_screen,camera_left,camera_right,camera_up,camera_down,camera_preset,camera_zoom_in,camera_zoom_out now: camera_full_screen,camera_left,camera_right,camera_up,camera_down,camera_preset,camera_zoom_in,camera_zoom_out #hooks:0 2020-11-22 09:56:05.011 openLuup.scheduler:: [297] Amcrest Dahua device startup completed: status=, msg=, name= 2020-11-22 09:56:05.012 luup_log:3: ALTUI: UPNPregisterDataProvider(3,Vera@192.168.1.14,http://127.0.0.1:3480/data_request?id=lr_HTTP_VeraBridgeMirror_192.168.1.14,[{ "default":"device.serviceId.name", "key":"mirror", "label":"Mirror", "type":"text" }]) 2020-11-22 09:56:05.012 luup.variable_set:: 3.urn:upnp-org:serviceId:altui1.DataStorageProviders was: {"emoncms":{"url":"","callback":"sendValueToStorage_emoncms","parameters":[{"default":1,"type":"number","key":"node... now: {"Vera@192.168.1.14":{"url":"http://127.0.0.1:3480/data_request?id=lr_HTTP_VeraBridgeMirror_192.168.1.14","callback... #hooks:0 2020-11-22 09:56:05.012 luup_log:3: ALTUI: UPNPregisterPlugin(3,urn:schemas-toggledbits-com:device:SiteSensor:1,J_SiteSensor1_ALTUI.js,SiteSensor_ALTUI.DeviceDraw,,,,SiteSensor_ALTUI.Favorite) 2020-11-22 09:56:05.016 luup.variable_set:: 3.urn:upnp-org:serviceId:altui1.PluginConfig was: {"urn:schemas-micasaverde-com:device:PowerMeter:1":{"DeviceDrawFunc":"ALTUI_PluginDisplays.drawPowerMeter","ScriptF... now: {"urn:schemas-micasaverde-com:device:PowerMeter:1":{"ScriptFile":"J_ALTUI_plugins.js","DeviceDrawFunc":"ALTUI_Plugi... #hooks:0 2020-11-22 09:56:05.017 luup_log:3: ALTUI: UPNPregisterPlugin(3,u
BTW I have tried the complete URL in the browser and that works.
-
Good news is that the plugin code is executing.
Stating the obvious but, did you check that the ip address and the credentials are setup?
It is working fine here (with the brackets). The display of the stream/snapshot is actually done by ALTUI. depending on the browser you use, it may buffer a bit strangely. -
Could you provide a screenshot of your attribute screen as well as a list of all your variables? I really have no idea why it isn't working for you. I even just added a camera to my openLuup setup and had no problem so something else is different. Are you seeing the camera control screen? Can you send commands to the camera like pan and tilt? What browser are you using? Can you try a different browser?
-
Ok, youre right, the plugin seems to work. I have tested with an other Amcrest model and that one does work. So the problem lies in the older models I have, that's a pity. I will have to do it through zoneminder then.
The PTZ does not seem to work however for my model.
I'm getting this error:
Unknown control type:js_button. See Debug
-
I'd be happy to improve the plugin to support more cameras if I can.
If the url is correct and the video is not working it is likely because the codec is not supported by the browser. If you tell me what camera it is, I will take a look.The error you are seeing about the button is not normal. I will take a look as well. This command is in javascript and is done by ALTUI. I don't believe it is in the plugin code but will check.
-
I don't get it. When I put the full URL directly in the browser window, like this, I get a stream (outside AltUI).
http://admin:<password>@192.168.1.17/cgi-bin/mjpg/video.cgi?channel=1&subtype=1
So that would mean it isn't the codec, right?
The model is: Amcrest IP3M-943B
-
Not sure why they would not work. It uses the same H264 and mjpg codec but your url uses mjpg. I have a bunch of IP3M-956/954 and they all work fine too.
Good catch on the js_button. I never noticed it but it seems to be inherited from deprecated code. I will fix that. Only some buttons were affected.I took advantage to fix a few thing around pan tilt/scanning. Released version 0.4.
This plugin was very raw when I took it over... I am finding so many things which were not quite right. -
I have tested the new version with my working model, but the buttons still do nothing. The error is gone and I don't see anything strange in the log.
2020-11-26 08:56:33.263 openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=377375215&Timeout=60&MinimumDelay=1500&_=1606377363201 HTTP/1.1 tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:33.642 luup.variable_set:: 10665.urn:upnp-org:serviceId:TemperatureSensor1.CurrentTemperature was: 19.60 now: 19.50 #hooks:0 2020-11-26 08:56:33.946 openLuup.server:: request completed (20648 bytes, 2 chunks, 682 ms) tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:34.059 openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=377375217&Timeout=60&MinimumDelay=1500&_=1606377363202 HTTP/1.1 tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:34.991 luup.variable_set:: 10664.urn:micasaverde-com:serviceId:HaDevice1.BatteryDate was: 1606377364 now: 1606377394 #hooks:0 2020-11-26 08:56:35.195 openLuup.server:: request completed (28287 bytes, 2 chunks, 1135 ms) tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:35.307 openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=377375219&Timeout=60&MinimumDelay=1500&_=1606377363203 HTTP/1.1 tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:37.593 openLuup.server:: GET /data_request?id=action&output_format=json&DeviceNum=297&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveLeft HTTP/1.1 tcp{client}: 0x55f5f5fd7d88 2020-11-26 08:56:37.593 luup.call_action:: 297.urn:micasaverde-com:serviceId:PanTiltZoom1.MoveLeft 2020-11-26 08:56:37.593 openLuup.server:: request completed (60 bytes, 1 chunks, 0 ms) tcp{client}: 0x55f5f5fd7d88 2020-11-26 08:56:37.630 openLuup.client:: WGET error status: -1, request: http://admin:DWvBqx6yT7SkMogw@192.168.1.18/cgi-bin/ptz.cgi?action=start&channel=0&code=Left&arg1=0&arg2=1&arg3=0 2020-11-26 08:56:37.934 openLuup.server:: request completed (19020 bytes, 2 chunks, 2626 ms) tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:38.091 openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=377375220&Timeout=60&MinimumDelay=1500&_=1606377363204 HTTP/1.1 tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:38.733 openLuup.client:: WGET error status: -1, request: http://admin:DWvBqx6yT7SkMogw@192.168.1.18/cgi-bin/ptz.cgi?action=stop&channel=0&code=Up&arg1=0&arg2=0&arg3=0 2020-11-26 08:56:39.741 openLuup.server:: GET /data_request?id=action&output_format=json&DeviceNum=297&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveRight HTTP/1.1 tcp{client}: 0x55f5f5fd7d88 2020-11-26 08:56:39.741 luup.call_action:: 297.urn:micasaverde-com:serviceId:PanTiltZoom1.MoveRight 2020-11-26 08:56:39.742 openLuup.server:: request completed (61 bytes, 1 chunks, 1 ms) tcp{client}: 0x55f5f5fd7d88 2020-11-26 08:56:39.775 openLuup.client:: WGET error status: -1, request: http://admin:DWvBqx6yT7SkMogw@192.168.1.18/cgi-bin/ptz.cgi?action=start&channel=0&code=Right&arg1=0&arg2=1&arg3=0 2020-11-26 08:56:40.280 openLuup.server:: request completed (19020 bytes, 2 chunks, 2188 ms) tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:40.424 openLuup.server:: GET /data_request?id=lu_status2&output_format=json&DataVersion=377375221&Timeout=60&MinimumDelay=1500&_=1606377363205 HTTP/1.1 tcp{client}: 0x55f5f5b61a78 2020-11-26 08:56:40.857 openLuup.client:: WGET error status: -1, request: http://admin:DWvBqx6yT7SkMogw@192.168.1.18/cgi-bin/ptz.cgi?action=stop&channel=0&code=Up&arg1=0&arg2=0&arg3=0 2020-11-26 08:56:41.476 openLuup.server:: GET /data_request?id=action&output_format=json&DeviceNum=297&serviceId=urn:micasaverde-com:serviceId:PanTiltZoom1&action=MoveUp HTTP/1.1 tcp{client}: 0x55f5f5fd7d88 2020-11-26 08:56:41.476 luup.call_action:: 297.urn:micasaverde-com:serviceId:PanTiltZoom1.MoveUp 2020-11-26 08:56:41.477 openLuup.server:: request completed (58 bytes, 1 chunks, 0 ms) tcp{client}: 0x55f5f5fd7d88 2020-11-26 08:56:41.497 openLuup.client:: WGET error status: -1, request: http://admin:DWvBqx6yT7SkMogw@192.168.1.18/cgi-bin/ptz.cgi?action=start&channel=0&code=Up&arg1=0&arg2=1&arg3=0 2020-11-26 08:56:41.600 openLuup.server:: request completed (19020 bytes, 2 chunks, 1176 ms) tcp{client}: 0x55f5f5b61a78
The working model is the Amcrest IP4M-1051
-
I am not getting any of the WGET errors in my logs. I am not sure what this status -1 means besides the fact that the camera is rejecting the call. I am also a bit surprised that your credentials in the url are only partially encoded. (the username is doesn't appear to be). Something doesn't seem right.
Honestly I have not gotten to the bottom of the stream. One of my cameras which I just added has all the pan and tilt buttons work so it is communicated properly but the video does not show. I tested on firefox and none of the cameras show any images.
Will try to dig deeper into this as I think it is more java code from ALTUI than it is a plugin/openLuup problem. -
Alright so I made some progress with this. Sorry I am not very good in JS so it took me a while to understand how ALTUI handles this.
I have updated the plugin which should enable getting images from the camera if your browser has the ability to disable cross origin restrictions (i.e Safari "develop" menu). I have tested this on firefox as well but unlike safari, firefox somehow sends an URL without the credentials... which means that you won't be able to see your camera feed. I submitted a pull request to @amg0 to implement credentials in ALTUI.
-