IpCamera: New IP Camera Binding

Yes, minus probably 10 lines of code. See here and anyone can change and build it.

I made a new build for you to try, same place as last time. Fingers crossed it works for you.

You did it, gotoPreset works! Great, thank you! :slight_smile:

One thing about the docs: It was not clear to me that snapshots.mjpeg only works if Snapshot URL is set to “ffmpeg”. If I leave it empty and the binding uses the native camera snapshot URL, then it does not work.

HLS is now working for me. My problem was that Chrome Desktop cannot play it… I am currently trying out a workaround. It works however nicely in the HABpanelViewer Android App.

I’d also like to make a suggestion for you to consider: Add support for Amcrest privacy mode on/off. I could find out the correct commands for that.

snapshots.mjpeg Works in all cases here with multiple cameras from multiple brands, sounds like your camera has issues with snapshots, you should contact support :wink: thanks for reporting back on the gotopresets working will test those changes on my cameras here.

Ever since I have switched the sub stream to H264, snapshots are working reliable with that camera.

I just checked again and snapshots.mjpeg did not work anymore even with ffmpeg as Snapshot URL. No errors/warnings in the log. I tried several times changing the config.

So, I cleared the Snapshot URL again and restarted openHAB and now snapshots.mjpeg is working with the native snapshot URL of the camera. I will let it run over night for testing.

Hey,

I just want to let u know that the cameras:

Reolink RLC-520
Reolink RLC-410-5MP

works fine for me !! :slight_smile:

maybe u want to add this information to you Post

I have captured REST commands for the privacy mode of my Amcrest IP2M-841B-V3. Could not find cgi-bin commands, yet.

Privacy mode on (Web):

POST /RPC2 HTTP/1.1^M
Host: 192.168.0.2^M
Connection: keep-alive^M
Content-Length: 213^M
Accept: application/json, text/javascript, */*; q=0.01^M
DNT: 1^M
X-Requested-With: XMLHttpRequest^M
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36^M
Content-Type: application/x-www-form-urlencoded; charset=UTF-8^M
Origin: http://192.168.0.2^M
Referer: http://192.168.0.2/^M
Accept-Encoding: gzip, deflate^M
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7^M
Cookie: secure; username=admin; DhWebClientSessionID=d4baee7485d55a42d924c631ceff6c81^M
^M
{"method":"configManager.setConfig","params":{"name":"LeLensMask","table":[{"Enable":true,"LastPosition":[-0.9555555555555556,0.035,0.0078125]}],"options":[]},"id":255,"session":"d4baee7485d55a42d924c631ceff6c81"}

HTTP/1.1 200 OK^M
X-XSS-Protection: 1;mode=block^M
X-Frame-Options: SAMEORIGIN^M
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'^M
Strict-Transport-Security: max-age=604800; includeSubDomains^M
CONNECTION: Keep-Alive^M
Set-Cookie:secure; HttpOnly^M
CONTENT-LENGTH: 96^M
^M
{"id":255,"params":{"options":null},"result":true,"session":"d4baee7485d55a42d924c631ceff6c81"}

Privacy mode off (Web):

POST /RPC2 HTTP/1.1^M
Host: 192.168.0.2^M
Connection: keep-alive^M
Content-Length: 214^M
Accept: application/json, text/javascript, */*; q=0.01^M
DNT: 1^M
X-Requested-With: XMLHttpRequest^M
User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.183 Safari/537.36^M
Content-Type: application/x-www-form-urlencoded; charset=UTF-8^M
Origin: http://192.168.0.2^M
Referer: http://192.168.0.2/^M
Accept-Encoding: gzip, deflate^M
Accept-Language: de-DE,de;q=0.9,en-US;q=0.8,en;q=0.7^M
Cookie: secure; username=admin; DhWebClientSessionID=8c92af61fadebdaeb0cd584e4bce7a84^M
^M
{"method":"configManager.setConfig","params":{"name":"LeLensMask","table":[{"Enable":false,"LastPosition":[-0.9555555555555556,0.035,0.0078125]}],"options":[]},"id":242,"session":"8c92af61fadebdaeb0cd584e4bce7a84"}

HTTP/1.1 200 OK^M
X-XSS-Protection: 1;mode=block^M
X-Frame-Options: SAMEORIGIN^M
Content-Security-Policy: script-src 'self' 'unsafe-inline' 'unsafe-eval'^M
Strict-Transport-Security: max-age=604800; includeSubDomains^M
CONNECTION: Keep-Alive^M
Set-Cookie:secure; HttpOnly^M
CONTENT-LENGTH: 96^M
^M
{"id":242,"params":{"options":null},"result":true,"session":"8c92af61fadebdaeb0cd584e4bce7a84"}

Privacy mode on (App):

{ "id" : 44564, "method" : "configManager.getConfig", "params" : { "channel" : 0, "name" : "LeLensMask" }, "session" : 2147464963 }
{"id":44564,"params":{"table":{"Enable":true,"LastPosition":[-0.9555555582046509,0.03500000014901161,0.00781250]}},"result":true,"session":2147464963}
{ "id" : 45076, "method" : "configManager.setConfig", "params" : { "channel" : 0, "name" : "LeLensMask", "table" : { "Enable" : false, "LastPosition" : [ -0.9555555582046509, 0.03500000014901161, 0.007812500000000000 ] } }, "session" : 2147464963 }

Privacy mode off (App):

{ "id" : 44564, "method" : "configManager.getConfig", "params" : { "channel" : 0, "name" : "LeLensMask" }, "session" : 2147464963 }
{"id":44564,"params":{"table":{"Enable":true,"LastPosition":[-0.9555555582046509,0.03500000014901161,0.00781250]}},"result":true,"session":2147464963}
{ "id" : 45076, "method" : "configManager.setConfig", "params" : { "channel" : 0, "name" : "LeLensMask", "table" : { "Enable" : false, "LastPosition" : [ -0.9555555582046509, 0.03500000014901161, 0.007812500000000000 ] } }, "session" : 2147464963 }

i ve got a Tp-link Tapo c310 camera.Nice build little cheap camera,easy setup and alarm and motion detection features.The binding autodiscovered it right away as a generic onvif and i watch it in my habpanel using ipcamera clickable widget.It doent have mjpeg or snapshot feature as far as i know but using the binding snapshot and mjpeg works just fine for the widget.Only one thing…if i reboot the camera or it goes offline for a while the widget stops updating the snapshot.Only the habpanel widget.I can still get a new snapshot using the “http://xxx.xxx.x.x:port/ipcamera.jpg” on a browser or stream it to a chromecast so i am sure snapshot feature is still working .I have to restart openhabian to make widget update snapshot again …Any ideas?

edit: something is changed,snapshot is working but when i click on the widget to start mjpeg i get

2020-11-15 21:13:15.169 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-rtsp_transport tcp -hide_banner -loglevel warning -i rtsp://kostas:xxxxxxxxx@192.168.1.16:554/stream1 -q:v 5 -r 2 -vf scale=640:-2 -update 1 http://127.0.0.1:8084/ipcamera.jpg

2020-11-15 21:13:16.507 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - rtsp://kostas:xxxxxxxxxx@192.168.1.16:554/stream1: Server returned 4XX Client Error, but not one of 40{0,1,3,4}

2020-11-15 21:16:50.125 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-rtsp_transport tcp -hide_banner -loglevel warning -i rtsp://kostas:xxxxxxxxxx@192.168.1.16:554/stream1 -q:v 5 -r 2 -vf scale=640:-2 -update 1 http://127.0.0.1:8084/ipcamera.jpg

2020-11-15 21:16:51.437 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - rtsp://kostas:xxxxxxxxxxxx@192.168.1.16:554/stream1: Server returned 4XX Client Error, but not one of 40{0,1,3,4}

i noticed that now when i add that camera in openhab and snapshot channel starts ,streaming at cam’s app is breaking down,i cant see stream at vlc.tinycam pro or at android Tapo app.When i delete camera from openhab i streaming starts working fine.
i have 3 other generic onvif cams and they r working fine jpg and mjpeg.

Blockquote. I can still get a new snapshot using the “http://xxx.xxx.x.x:port/ipcamera.jpg” on a browser or stream it to a chromecast so i am sure snapshot feature is still working .

Then it is not a binding issue, need to start your own thread as it may be a Habpanel or Widget issue. You should not have to do a restart, worse case it should be just a refresh in the browser serving Habpanel.
Also it would be worth trying out the snapshots.mjpeg stream instead of doing jpg’s.

EDIT: regarding the 40x error it is pretty common for cameras to only allow a limited amount of con current open streams. My guess is the camera is refusing as you have it open too many times. Some cameras allow a stream to be open up to 20 times, whilst others only allow it to be open 1 single time.
If you need to use it multiple times, the binding can serve multiple requests without issues, so change to using the URLS from the output of this binding to feed your other use cases.

Thanks for reporting this, I made some changes that will only go into the V3 binding when the changes get merged. The default quality is now a lot better.

@Kahzia
Thanks for reporting, have added to the first post.

about the camera,i dont know what but when i change the static reserved ip now it can stream right at multiple clients.
Now about the widget ,it works ok,jpg and mjpeg with the other 3 cheap generic onvif cameras that i own and at the Tapo C310 jpg works but no mjpeg.When i click it does not opens the mjpeg stream…

@matt1 did you saw some interesting solution how to “catch” Ezviz DB1 button press:

I have openhab running on a windows server. I installed the DNS services on my server en changed the DNS address on my Ezviz DB1 trough Batch Configuration to point to my DNS server.
I Enabled logging on my DNS server and it writes the log to c:\temp\log.txt I then have a powershell looping trough the log sending a http request to my openhab.
Here is an example of the DNS request that is been made everytime the doorbell is pressed:
12/11/2020 11:01:58 0C04 PACKET 00000231F06CBFF0 UDP Rcv 192.168.1.37 0030 Q [0001 D NOERROR] A (5)alarm(2)eu(2)s3(9)amazonaws(3)com(0)
Here is an example of how to use this trough powershell:

Get-Content -Path C:\temp\log.txt -Tail 3 -Wait | where { $_ -match “alarm” } |
ForEach-Object{
Write-Host “DOORBELL PRESSED”
}

In the example above the everytime a dns request in the log containts the word alarm, powershell will echo Doorbell Pressed.
You can switch this to a http request answering to a virtual switch in openhab. I hope to find a better solution in the future.

Did anybody suceed with the Hicam S6?

Thanks for posting as that could be useful, have put link in the thread dedicated for that model. I find that more than 90% of the people that visit my house don’t push the bell, they still knock on the door. So I just use the PIR to detect and then send a video to me with telegram that includes audio. Couriers tend to be too busy to look for bells since Covid started they don’t want signatures, so it is dump and run with a quick rap on the door. Also most Crooks that are casing the place to rob will not press a video camera button.

agree with this :slight_smile:

Found out the cgi-bin commands for the Amcrest Privacy Mode (hopefully works also with Dahua). This is easier than the REST API I posted above.

/cgi-bin/configManager.cgi?action=getConfig&name=LeLensMask

table.LeLensMask[0].Enable=false
table.LeLensMask[0].LastPosition[0]=0.072778
table.LeLensMask[0].LastPosition[1]=0.035000
table.LeLensMask[0].LastPosition[2]=0.007812

/cgi-bin/configManager.cgi?action=setConfig&LeLensMask[0].Enable=true
/cgi-bin/configManager.cgi?action=setConfig&LeLensMask[0].Enable=false  

I think, I read somewhere, that the binding supports sending custom commands to the camera, so I could use this right away. But I cannot find this info anymore.

thx matt

@matt1 I created a pull request for the Privacy Mode, implemented for Amcrest and Dahua things:

Hello,

I have a new Dahua XVR5108HS-I2 and I want to use the SMD Plus feature. The Thing is online but from “Motion Alarm” channel no information is coming.
Do you know if SMD Plus is supported by IP Camera binding and how can I configured.

Thank you in advance!
Colcm

@matt1 what about sound options using plugin with all door bells like EZVIZ db1 ant etc? Its possible to implement?

See the readme under the heading setup for each brand.

@Vaikis2006
No idea, have u seen anyone else doing it even in another project to prove it can be done? Better to post in the thread for that camera.