IpCamera: New IP Camera Binding

Hello,

I will open an GitHub issue an put all the information there.
I found this GitHub but is archived an is read-only:

Where can I create a new issue?

See my post above.

The issue was created:

UPDATE: Please disregard. I had accidentally created a second ipcamera Thing and was looking at the wrong thing when doing the tests.

Hi All,

Running OH 2.5.10.

I’m trying to use the ipcamera binding to capture an image using ffmpeg based on ffmpeg motion detection on my Lorex (HTTP ONLY) camera.

These are the following channels I have linked to get this information:

Poll Image
Image
FFmpeg Motion Alarm ON/OFF/DIMMER
FFmpeg Motion Alarm
MJPEG URL
Image URL

I also have the following Thing parametre set:

Update Image channel when:
Start Motion Alarm (2)

Some interesting observations:

  1. I do get a mjpeg feed at the MJPEG URL
  2. I do get a jpg image at the Image URL. However, the image never updates.
  3. I do get the Motion Alarm to trigger when motion is detected on the camera
  4. When I adjust the Motion Alarm dimmer, it seems to get more sensitive the lower the number. Is that the correct way it should function? I would have thought the larger the number, the more sensitive the motion detection.
  5. The Image channel never gets updated. I would have expected the image channel to have updated when motion was detected.

I suspect there is something wrong with my configuration.

Any help would be greatly appreciated. Thanks.

Cheers,
Randy

@matt1 Tested again about losing the alarm stream because of reboot.
It takes pretty exactly 2 hours for the binding to realize that the stream is dead. Then it reconnects.
I’ll try adding code so that the binding immediately reacts to a reboot.

Edit:
The binding already enables TCP keep alive, but the default keep alive settings on Linux are rather relaxed and so it takes 2 hours to recognize that the alarm stream is dead. I changed the Linux settings like this (as recommended at https://webhostinggeeks.com/howto/configure-linux-tcp-keepalive-setting/):

echo 60 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 10 > /proc/sys/net/ipv4/tcp_keepalive_intvl
echo 6 > /proc/sys/net/ipv4/tcp_keepalive_probes

With these settings, the binding restarts the alarm stream 1 minute after the reboot.
But I am not sure yet, if this has negative effects on the rest of the system.

I can confirm this is a bug. I tested it on multiple of my cameras and could reproduce it if I set the gif preroll to 0 which will be why I did not pick this up in my testing. If you set it to a number above 0 then the binding will fetch a snapshot at the poll rate and detect the camera has gone offline as the snapshot fails to work. Does this fix it for you as a temporary work around?
I have already fixed it and will do a PR soon.

EDIT: @sidamos I uploaded a precompiled jar if you want to try it out, see here for link and info on other changes:

The channel motionAlarm sometimes does not flip back to OFF and sometimes does not flip to ON for motion. Tested with 2.5.10 snapshot.

Last night, the camera detected 4 motion events but only the 1st and 4th resulted in running my rule, which listens for motionAlarm becoming ON and then starts an mp4 recording for 30s.

Trace 1:

2020-11-29 06:50:01.873 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 06:50:01.943 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:96

Code=VideoMotion;action=Start;index=0;data={
   "Id" : [ 0 ],
   "RegionName" : [ ":
2020-11-29 06:50:01.944 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:Region1" ]
}


:
2020-11-29 06:50:01.945 [WARN ] [ipse.smarthome.model.script.ipcamera] - 2020-11-29_06-50-01
2020-11-29 06:50:01.946 [DEBUG] [ng.ipcamera.internal.IpCameraActions] - Recording 2020-11-29_06-50-01.mp4 for 30 seconds.
2020-11-29 06:50:01.946 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-y -t 30 -hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://admin:xxxxx@192.168.0.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif -c:v copy -c:a copy /video/ipcamera/2020-11-29_06-50-01.mp4
2020-11-29 06:50:02.076 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:145

Code=RtspSessionDisconnect;action=Stop;index=0:
2020-11-29 06:50:02.076 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:;data={
   "Device" : "192.168.0.7",
   "StreamType" : "Main",
   "UserAgent" : " Lavf58.45.100"
}


:
2020-11-29 06:50:02.153 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 06:50:02.587 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "D:
2020-11-29 06:50:02.587 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ata" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" :
2020-11-29 06:50:02.587 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:: "\/var\/tmp\/jpg\/0\/20201129065001ch01.jpg",
   "Index" : 0,
   "Size:
2020-11-29 06:50:02.587 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:" : 118907,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 06:50:02.721 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:95

Code=VideoM:
2020-11-29 06:50:02.721 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:otion;action=Stop;index=0;data={
   "Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 06:50:02.751 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "F:
2020-11-29 06:50:02.752 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ile" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/06hour\/jpg\/06.50.01[:
2020-11-29 06:50:02.752 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:M][0@0][0].jpg",
   "Size" : 118859,:
2020-11-29 06:50:02.753 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:
   "StoragePoint" : "NULL"
}


:
2020-11-29 06:50:03.581 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFi:
2020-11-29 06:50:03.581 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:le;action=Pulse;index=0;data={
   "D:
2020-11-29 06:50:03.582 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ata" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
  :
2020-11-29 06:50:03.582 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	: "Event" : "VideoMotion",
   "File" :
2020-11-29 06:50:03.582 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:: "\/var\/tmp\/jpg\/0\/20201129065002ch01.jpg",
   "Index" : 0,
   "Size:
2020-11-29 06:50:03.582 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:" : 119129,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 06:50:03.683 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;actio:
2020-11-29 06:50:03.683 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:n=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/06hour\/jpg\/06.50.02[M][0@0][0].jpg",
   "Size" : 119081,
   "Sto:
2020-11-29 06:50:03.684 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ragePoint" : "NULL"
}


:
2020-11-29 06:50:04.237 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [mp4 @ 0x56359e354e00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
2020-11-29 06:50:04.589 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
  :
2020-11-29 06:50:04.589 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	: "Event" : "VideoMotion",
   "File" : "\/var\/tmp\/jpg\/0\/20201129065003ch01.jpg",
   "Index" : 0,
   "Size:
2020-11-29 06:50:04.590 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:" : 118996,
   "StoragePoint" : "Tem:
2020-11-29 06:50:04.590 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:porary"
}


:
2020-11-29 06:50:04.686 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/06hour\/jpg\/06.50.03[M][0@0][0].jpg",
   "Size" : 118948,
   "StoragePoint" : "NU:
2020-11-29 06:50:04.686 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:LL"
}


:
2020-11-29 06:50:30.002 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/home/mythtv/openHAB/nesthello.sh'
2020-11-29 06:50:32.281 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:146

Code=RtspSessionDisconnect;action=Start;index=:
2020-11-29 06:50:32.288 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:0;data={
   "Device" : "192.168.0.7",
   "StreamType" : "Main",
   "UserAgent" : " Lavf58.45.100"
}


:
2020-11-29 06:50:32.930 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:176

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/mnt\/sd\/2020-11-29\/001\/:
2020-11-29 06:50:32.931 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:dav\/06\/06.49.54-06.50.32[M][0@0][0:
2020-11-29 06:50:32.931 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:].mp4",
   "Size" : 7618494,
   "Sto:
2020-11-29 06:50:32.931 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ragePoint" : "NULL"
}


:

Events 1:

2020-11-29 06:50:01.946 [vent.ItemStateChangedEvent] - AmcrestCamera01_MotionAlarm changed from OFF to ON
2020-11-29 06:50:01.947 [vent.ItemStateChangedEvent] - AmcrestCamera01_MP4RecordingSeconds changed from 0 to 30
2020-11-29 06:50:33.086 [vent.ItemStateChangedEvent] - AmcrestCamera01_MP4RecordingSeconds changed from 30 to 0

motionAlarm channel changed from OFF to ON, but not back. My rule ran.

Trace 2:

2020-11-29 07:56:16.493 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 07:56:16.563 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:96

Code=VideoMotion;action=Start;index=0;data={
   "Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 07:56:16.788 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 07:56:16.860 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:95

Code=VideoMotion;action=Stop;index=0;data={
   :
2020-11-29 07:56:16.861 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:"Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 07:56:17.429 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      ":
2020-11-29 07:56:17.430 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" :
2020-11-29 07:56:17.430 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:: "\/var\/tmp\/jpg\/0\/2020112907561:
2020-11-29 07:56:17.430 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:6ch01.jpg",
   "Index" : 0,
   "Size" : 118870,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 07:56:17.531 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/07hour\/jpg\/07.56:
2020-11-29 07:56:17.532 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:.16[M][0@0][0].jpg",
   "Size" : 118822,
   "StoragePoint" : "NULL"
}


:
2020-11-29 07:56:18.429 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" :
2020-11-29 07:56:18.429 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:: "\/var\/tmp\/jpg\/0\/20201129075617ch01.jpg",
   "Index" : 0,
   "Size" : 118974,
   "StoragePoint" : "Tem:
2020-11-29 07:56:18.430 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:porary"
}


:
2020-11-29 07:56:18.502 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/07hour\/jpg\/07.56.17[M][0@0][0].jpg",
   "Size" : 118926,
   "StoragePoint" : "NULL"
}


:
2020-11-29 07:56:30.003 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/home/mythtv/openHAB/nesthello.sh'
2020-11-29 07:56:47.139 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:176

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/mnt\/sd\/2020-11-29\/001\/:
2020-11-29 07:56:47.139 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:dav\/07\/07.56.08-07.56.46[M][0@0][0].mp4",
   "Size" : 7596839,
   "StoragePoint" : "NULL"
}


:

Events 2:

2020-11-29 07:56:16.861 [vent.ItemStateChangedEvent] - AmcrestCamera01_MotionAlarm changed from ON to OFF

motionAlarm changed back to OFF. My rule did not run, because it listens for becoming ON.

Trace 3:

2020-11-29 08:13:05.656 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 08:13:05.723 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/pla:
2020-11-29 08:13:05.724 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:in
Content-Length:96

Code=VideoM:
2020-11-29 08:13:05.728 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:otion;action=Start;index=0;data={
   "Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 08:13:05.881 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" : "\/var:
2020-11-29 08:13:05.881 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:\/tmp\/jpg\/0\/20201129081305ch01.jpg",
   "Index" : 0,
   "Size" : 118594,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 08:13:05.936 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 08:13:06.003 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/08hour\/jpg\/08.13.05[M][0@0][0].jpg",
   "Size" : 118546,
   "StoragePoint" : "NULL"
}


:
2020-11-29 08:13:06.873 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:95

Code=VideoMotion;action=Stop;index=0;data={
   "Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 08:13:06.888 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      ":
2020-11-29 08:13:06.888 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:RegionName" : [ "Region1" ]
   },
  :
2020-11-29 08:13:06.888 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	: "Event" : "VideoMotion",
   "File" :
2020-11-29 08:13:06.889 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:: "\/var\/tmp\/jpg\/0\/2020112908130:
2020-11-29 08:13:06.889 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:6ch01.jpg",
   "Index" : 0,
   "Size:
2020-11-29 08:13:06.889 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:" : 118719,
   "StoragePoint" : "Tem:
2020-11-29 08:13:06.897 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:porary"
}


:
2020-11-29 08:13:06.951 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/08hour\/jpg\/08.13.06[:
2020-11-29 08:13:06.952 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:M][0@0][0].jpg",
   "Size" : 118671,:
2020-11-29 08:13:06.952 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:
   "StoragePoint" : "NULL"
}


:
2020-11-29 08:13:07.885 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" : "\/var\/tmp\/jpg\/0\/20201129081307ch0:
2020-11-29 08:13:07.886 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:1.jpg",
   "Index" : 0,
   "Size" : 118866,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 08:13:07.967 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135:
2020-11-29 08:13:07.967 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:\/2020-11-29\/08hour\/jpg\/08.13.07[M][0@0][0].jpg",
   "Size" : 118818,:
2020-11-29 08:13:07.968 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:
   "StoragePoint" : "NULL"
}


:
2020-11-29 08:13:30.002 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/home/mythtv/openHAB/nesthello.sh'
2020-11-29 08:13:37.051 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:176

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/mnt\/sd\/2020-11-29\/001\/dav\/08\/08.12.58-08.13.36[M][0@0][0].mp4",
   "Size" : 7688236,
   "StoragePoint" : "NULL"
}


:

No events occurred at all.

Trace 4:

Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 08:31:18.357 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:96

Code=VideoMotion;action=Start;index=0;data={
  :
2020-11-29 08:31:18.357 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	: "Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 08:31:18.358 [WARN ] [ipse.smarthome.model.script.ipcamera] - 2020-11-29_08-31-18
2020-11-29 08:31:18.358 [DEBUG] [ng.ipcamera.internal.IpCameraActions] - Recording 2020-11-29_08-31-18.mp4 for 30 seconds.
2020-11-29 08:31:18.359 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - Starting ffmpeg with this command now:-y -t 30 -hide_banner -loglevel warning -rtsp_transport tcp -i rtsp://admin:xxxxx@192.168.0.18:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif -c:v copy -c:a copy /video/ipcamera/2020-11-29_08-31-18.mp4
2020-11-29 08:31:18.521 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:145

Code=RtspSessionDisconnect;action=Stop;index=0:
2020-11-29 08:31:18.522 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:;data={
   "Device" : "192.168.0.7",
   "StreamType" : "Main",
   "UserAgent" : " Lavf58.45.100"
}


:
2020-11-29 08:31:18.571 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:41

Code=VideoMotionInfo;action=State;index=0

:
2020-11-29 08:31:18.876 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:95

Code=VideoMotion;action=Stop;index=0;data={
   "Id" : [ 0 ],
   "RegionName" : [ "Region1" ]
}


:
2020-11-29 08:31:19.192 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "D:
2020-11-29 08:31:19.192 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ata" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" : "\/var\/tmp\/jpg\/0\/2020112908311:
2020-11-29 08:31:19.193 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:8ch01.jpg",
   "Index" : 0,
   "Size:
2020-11-29 08:31:19.193 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:" : 119659,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 08:31:19.293 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "F:
2020-11-29 08:31:19.294 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:ile" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/08hour\/jpg\/08.31.18[:
2020-11-29 08:31:19.294 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:M][0@0][0].jpg",
   "Size" : 119611,
   "StoragePoint" : "NULL"
}


:
2020-11-29 08:31:20.185 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:272

Code=NewFile;action=Pulse;index=0;data={
   "Data" : {
      "Id" : [ 0 ],
      "RegionName" : [ "Region1" ]
   },
   "Event" : "VideoMotion",
   "File" : "\/var:
2020-11-29 08:31:20.185 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:\/tmp\/jpg\/0\/20201129083119ch01.jpg",
   "Index" : 0,
   "Size" : 119621,
   "StoragePoint" : "Temporary"
}


:
2020-11-29 08:31:20.248 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:184

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/tmp\/NFS1\/AMC0570B_6AF135\/2020-11-29\/08hour\/jpg\/08.31.19[:
2020-11-29 08:31:20.248 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:M][0@0][0].jpg",
   "Size" : 119573,:
2020-11-29 08:31:20.253 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:
   "StoragePoint" : "NULL"
}


:
2020-11-29 08:31:20.660 [DEBUG] [hab.binding.ipcamera.internal.Ffmpeg] - [mp4 @ 0x563fc3deae00] Timestamps are unset in a packet for stream 0. This is deprecated and will stop working in the future. Fix your code to set the timestamps properly
2020-11-29 08:31:30.003 [INFO ] [lipse.smarthome.io.net.exec.ExecUtil] - executed commandLine '/home/mythtv/openHAB/nesthello.sh'
2020-11-29 08:31:48.828 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:146

Code=RtspSessionDisconnect;action=Start;index=0;data={
   "Device" : "192.168.0.7",
   "StreamType" : "Main",
   "UserAgent" : " Lavf58.45.100"
}


:
2020-11-29 08:31:49.105 [TRACE] [era.internal.handler.IpCameraHandler] - HTTP Result back from camera is 	:--myboundary
Content-Type: text/plain
Content-Length:176

Code=NewFile;action=Pulse;index=0;data={
   "File" : "\/mnt\/sd\/2020-11-29\/001\/dav\/08\/08.31.11-08.31.48[M][0@0][0].mp4",
   "Size" : 7451449,
   "StoragePoint" : "NULL"
}


:

Events 4:

2020-11-29 08:31:18.358 [vent.ItemStateChangedEvent] - AmcrestCamera01_MotionAlarm changed from OFF to ON
2020-11-29 08:31:18.359 [vent.ItemStateChangedEvent] - AmcrestCamera01_MP4RecordingSeconds changed from 0 to 30
2020-11-29 08:31:18.877 [vent.ItemStateChangedEvent] - AmcrestCamera01_MotionAlarm changed from ON to OFF
2020-11-29 08:31:49.563 [vent.ItemStateChangedEvent] - AmcrestCamera01_MP4RecordingSeconds changed from 30 to 0

Worked OK, motionAlarm changed from OFF to ON and back.

Edit:
Analyzed source code and logs and found interesting things for the 4 motion events:

1. 
Code=VideoMotion;action=Start;index=0;data={
Code=VideoM:
otion;action=Stop;index=0;data={
2.
Code=VideoMotion;action=Start;index=0;data={
Code=VideoMotion;action=Stop;index=0;data={
3.
Code=VideoM:
otion;action=Start;index=0;data={
Code=VideoMotion;action=Stop;index=0;data={
4.
Code=VideoMotion;action=Start;index=0;data={
Code=VideoMotion;action=Stop;index=0;data={

It looks like the messages from the camera sometimes get splitted. This happened for event 1. and 3. resulting in the strang behavior of the motionAlarm channel.
Actually, it also happened for event 2. and 4., but it did no harm there.

This is probably a problem in the binding, if I understand that correctly:

It does not look too complicated fixing this:

EDIT: @sidamos I uploaded a precompiled jar if you want to try it out, see here for link and info on other changes:

I can confirm that this reconnects after a reboot of the camera.
It requests a snapshot every 8 seconds from the camera.
The downside is, that this will write a jpg to my storage every 8s when I configure the camera to do snapshots images for motion events.
I tried only enabling NAS storage for motion events for snapshots, but still it writes a jpg to the NAS every time openHAB requests a snapshot.
I can live with that, because I do not really need snapshot images for motion events.

Fixed but have not tested nor built it yet, see my repo for changes.

Thanks, I will try to reproduce the issue and then try to get your changes to 2.5.10 for my production system to see, if it is fixed with that.
Cool, I see that you are using the HTTP protocol, that’s even better than the String approach.

EDIT: @sidamos I uploaded a precompiled jar if you want to try it out, see here for link and info on other changes:

There is a problem with using the snapshot URL for checking if the camera rebooted:
It does not work if setting “ffmpeg” as snapshot URL. Then it does not do checks.
Also, after further thinking, requesting a snapshot every 8s is probably problematic for some cameras. For example, mine does not return a snapshot if the sub stream is MJPEG. Other Amcrests sometimes stop returning snapshots.
Could you use another “simple” GET for some config for checking if the camera is still there? This would work in all cases.

If you have a camera that can not handle that then you should contact their support and complain as it is a basic feature and one that should work if it is to call itself ONVIF compatible.

No camera that has an alarm stream should need to set that, if it does it should be considered a camera firmware bug. ONVIF standard requires a snapshot for it to be considered able to be advertised as ONVIF compliant.

No it would not as there are cameras with only a RTSP server and nothing more. Cameras with only a snapshot url and nothing more in them. ESP32 based cameras that can only do snapshots and mjpeg streams and nothing more. But all of these do not have alarm streams, which brings me back to my statement that if it has an alarm stream it should have working snapshots unless it is a bug in the cameras firmware.

This binding is huge and covers many brands and methods, so it is like 6 bindings all thrown into 1 which makes testing all use cases very difficult especially when most people appear to not raise an issue when it is found.

Thanks for raising these multiple things recently, if you notice something then please test, narrow it down and then mention it as I probably have an idea on where to look or how to fix.

Hey,

ive got some problems with installing the yi dome 1080p in openhab. I use the ipcamera binding and made some configuration with visual studio Code.

I updated my cam with the yi hack from roleoroleo and tested also onvif with the onvif device manager without problems. Could pan and tilt. Then i tried to configure it in openhab, got an online Status, but no possibility to move the camera.

I hope that anyone can help me, no ideas to solve the problem.

Chris

Try this version If your using 2.5.x
http://www.pcmus.com/openhab/IpCameraBinding/ipcamera-2020-11-15.zip

A few compatibility fixes went into that build and are included in the V3.0 builds.

Also try turning using all four of the movement methods that the documentation explains as many cameras do not support all the types of movements.

1 Like

Had been using updateGif channel to create 10 second shorts (via a DSL rule) when my zwave PIR detected motion in 2.5.x. Migrated to OH3 M5 and can’t find that channel to start the recording. I also can no longer find in the documentation. I see the external motion channel, but is unclear what that will do. I’ve searched the 2194 entries in this post for updateGif and could not find where (or if) it was depreciated. BTW image and .jpeg & .jpg streaming work fine. Could use a pointer.

Bob

You have to use an action now in V3. See updated documentation here. When V3 goes live in a few weeks this will be reachable on the website.

Thanks a bunch !
I should have asked sooner :crazy_face:

Bob

As an FYI … I had trouble with your script (CommandLine /bin/mv, etc.) to time date the Gifs in OH3 (Worked perfect in OH2.5). Could not find the issue, but realized with the new Action, could time stamp the output directly.

> rule "Front_Door camera Zooz motion"
> when
>     Item  FrontDoorMotion38_AlarmMotion changed to ON
> then
>    val String timeNow = String::format( "%1$tY%1$tm%1$td-%1$tT", new java.util.Date ).replace(":", "")
>    getActions("ipcamera", "ipcamera:onvif:1921680133").recordGIF(timeNow,10)
> end

Tried different Types of Moving: absolute, relative, continouus , nothing worked. Is there any other preference which i should know? Camera is still showing online status, so i think that something happens there.

Hi everyone,

Some time ago, before ipcamera addon was in official openhab addons, I use this binding (ipcamera-2020-04-08.zip) for GIF creation and line crossing detections.

After migrating to OH 2.5.10 I have two problems.

  1. When binding is loading I get errors:
==> /opt/openhab/userdata/logs/openhab.log <==
2020-12-09 23:04:45.997 [WARN ] [me.config.core.internal.ConfigMapper] - Could not set field value for field 'updateImageWhen': Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
java.lang.IllegalArgumentException: Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:167) ~[?:1.8.0_265]
        at sun.reflect.UnsafeFieldAccessorImpl.throwSetIllegalArgumentException(UnsafeFieldAccessorImpl.java:171) ~[?:1.8.0_265]
        at sun.reflect.UnsafeObjectFieldAccessorImpl.set(UnsafeObjectFieldAccessorImpl.java:81) ~[?:1.8.0_265]
        at java.lang.reflect.Field.set(Field.java:764) ~[?:1.8.0_265]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:523) ~[bundleFile:2.6]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:500) ~[bundleFile:2.6]
        at org.apache.commons.lang.reflect.FieldUtils.writeField(FieldUtils.java:560) ~[bundleFile:2.6]
        at org.eclipse.smarthome.config.core.internal.ConfigMapper.as(ConfigMapper.java:101) [bundleFile:?]
        at org.eclipse.smarthome.config.core.Configuration.as(Configuration.java:80) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.getConfigAs(BaseThingHandler.java:232) [bundleFile:?]
        at org.openhab.binding.ipcamera.internal.handler.IpCameraHandler.initialize(IpCameraHandler.java:1595) [bundleFile:?]
        at org.eclipse.smarthome.core.thing.binding.BaseThingHandler.thingUpdated(BaseThingHandler.java:166) [bundleFile:?]
        at sun.reflect.GeneratedMethodAccessor220.invoke(Unknown Source) ~[?:?]
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_265]
        at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_265]
        at org.eclipse.smarthome.core.internal.common.AbstractInvocationHandler.invokeDirect(AbstractInvocationHandler.java:152) [bundleFile:?]
        at org.eclipse.smarthome.core.internal.common.Invocation.call(Invocation.java:52) [bundleFile:?]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_265]
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_265]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_265]

==> /opt/openhab/userdata/logs/events.log <==
2020-12-09 23:04:46.007 [me.event.ThingUpdatedEvent] - Thing 'ipcamera:hikvision:FURTKA' has been updated.

My config looks like:

Thing ipcamera:hikvision:FURTKA "FURTKA" @ "Cameras" [
    ipAddress="192.168.XXX.YYY",
    password="XXXXX",
    username="admin",
    pollTime=1000,
    ipWhitelist="DISABLE",
    serverPort=50011,
    updateImageWhen=2,
    onvifMediaProfile=1,
    mjpegUrl="ffmpeg",
    nvrChannel=1,
    gifPreroll=0,
    gifPostroll=3,
    ffmpegOutput="/tmpfs/cam01/",
    onvifPort=8000, //normally 80 check what it needs
    port=80,
    ffmpegInput="rtsp://192.168.XXX.YYY:554/ISAPI/Streaming/channels/101"
]

I try to define updateImageWhen=“1” but I get the same error:

Could not set field value for field 'updateImageWhen': Can not set java.lang.String field org.openhab.binding.ipcamera.internal.CameraConfig.updateImageWhen to java.math.BigDecimal

I use now the snapshot version:

openhab> bundle:list |grep -i ipcame
317 │ Active │  80 │ 2.5.10.202011141152     │ openHAB Add-ons :: Bundles :: IpCamera Binding
openhab> feature:list | grep -i ipcam
openhab-binding-ipcamera                          │ 2.5.10           │ x        │ Started     │ openhab-addons-2.5.10        │ ipcamera Binding
openhab>

The second problem is that, the recordGif stops working. I have rule like this:

rule "FURTKA Line Crossing detected"
when
  Item CamFurtkaLineCrossingAlarm changed to ON
then
  if (CamFurtkaRecordingGif.state == 0 || CamFurtkaRecordingGif.state == NULL ) {
    getActions("ipcamera", "ipcamera:hikvision:FURTKA").recordGIF("ipcamera",3)
  }
end

And I start to get errors in OH2.5.10:

2020-12-09 23:07:28.635 [ERROR] [ntime.internal.engine.RuleEngineImpl] - Rule 'FURTKA Line Crossing detected': Instance is not a IpCamera class.

And my items:

Switch CamFurtkaStartHLS "Start HLS" { channel="ipcamera:hikvision:FURTKA:startStream" }
Number CamFurtkaRecordingGif "Update GIF" { channel="ipcamera:hikvision:FURTKA:recordingGif" }
Image CamFurtkaImage "Picture" { channel="ipcamera:hikvision:FURTKA:image" }
Switch CamFurtkaUpdateImage "Get new picture" { channel="ipcamera:hikvision:FURTKA:pollImage" }
//Switch CamFurtkaCreateGif "Create animated GIF" { channel="ipcamera:hikvision:FURTKA:updateGif" }
Switch CamFurtkaEnableLineCrossing "Line Crossing Alarm on/off" { channel="ipcamera:hikvision:FURTKA:enableLineCrossingAlarm" }
Switch CamFurtkaLineCrossingAlarm "Line Crossing detected" { channel="ipcamera:hikvision:FURTKA:lineCrossingAlarm" }
DateTime CamFurtkaLastMotionTime "Time motion was last detected [%1$ta %1$tR]"
String CamFurtkaLastMotionType "Last Motion Type" { channel="ipcamera:hikvision:FURTKA:lastMotionType" }

Can anyone help me?