Why won't my camera save a GIF to my drive?

  • Platform information:

    • Hardware: x86_64 / 8 Gb RAM / 64 Gb drive
    • OS: Debian 12.9
    • Java Runtime Environment: openjdk 21.0.6
    • openHAB version: OpenHab 4.3.2-1
  • Issue of the topic:

Dahua Camera with API Thing, GIF Recording Channel, Motion Alarm Channel, MJPEG URL Channel items linked to it. For whatever reason, it will not save a GIF to my drive, or anywhere else that I can see. I have changed permissions for my GIF folder to drwxrwxrwx. I have also made a rule to record a gif, but that doesn’t seem to work either. No logged issues that I see, either. Thoughts?

I am now seeing this in my log:

Welcome to the OH forum
Not an expert on the IP camera and may have non-standard setup, but here goes.
1)

UID: ipcamera:reolink:1921680247
label: Patio Camera
thingTypeUID: ipcamera:reolink
configuration:
  mjpegOptions: -q:v 5 -r 2 -vf scale=640:-2 -update 1
  ipAddress: 192.168.0.247
  updateImageWhen: "0"
  gifPreroll: 0
  onvifPort: 8000
  ffmpegLocation: /usr/bin/ffmpeg
  onvifEventServiceType: 0
  ipWhitelist: DISABLE
  mp4OutOptions: -c:v copy -c:a copy
  pollTime: 1000
  useToken: false
  password: xxxxxxxxxxxx
  port: 80
  snapshotUrl: http://192.168.0.247/cgi-bin/api.cgi?cmd=Snap&channel=0&rs=wuuPhkmUCeI9WG7C&user=admin&password=reec1230
  nvrChannel: 0
  snapshotOptions: -an -vsync vfr -q:v 2 -update 1
  ptzContinuous: true
  onvifMediaProfile: 0
  gifOutOptions: -r 2 -filter_complex
    scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse
  hlsOutOptions: -strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy
    -hls_flags delete_segments -hls_time 2 -hls_list_size 4
  1. I do not have a fffmpeg output location. I use the default Leave this blank and the binding will use the openHAB userdata folder. (userdata/ipcamera).
  2. I trigger a rule (DSL) from a zwave sensor to the camera using getActions("ipcamera", "ipcamera:reolink:1921680200").recordGIF(timeNow,10)
  3. Also have a widget on the overview page for live snapshots
        - component: oh-image-card
          config:
            action: url
            actionUrl: http://192.168.0.186:8080/ipcamera/1921680247/snapshots.mjpeg
            actionUrlSameWindow: true
            item: PatioCamera_Image

Hope that helps a bit

1 Like

You need to enable TRACE logging on the ipcamera binding and see what is happening when you try and record. The logs do not get much detail unless you enable TRACE level.

1 Like

timenow needs to be a string and is the filename of the recorded gif, not a time something.


.recordGIF("ipcamera",10)

Maybe a quirk of DSL, but it works for me. Note of caution for the OP, however.

Arghh, sorry, I did not pay enough attention to this post. I was on my phone and thought that line was part of the error description of the OP.
I definitely believe you are posting working solutions, sorry about that.

1 Like

Thanks, Bob.

I have a rule as well- but it also just doesn’t seem to be working either:


configuration: {}
triggers:
  - id: "1"
    configuration:
      itemName: Dahua_Camera_with_API_Motion_Alarm
      state: ON
    type: core.ItemStateUpdateTrigger
conditions: []
actions:
  - inputs: {}
    id: "2"
    configuration:
      config: ipcamera:dahua:Camera
      filename: test
      secondsToRecord: 2
    type: ipcamera.recordGIF#45d20840961e09b4e33263a5c4265a73

I have been around OH for a while but am too lazy to change my old working rules to the UI, so can’t help with that rule.

Also note that the IPCamera developer is @matt1, so mind his suggestion. The binding can be put in TRACE from the Setting UI page over on the right (Addons). Then trigger a test and paste the results back here using the </> icon, so they are easier to read.

1 Like

Hi Matt,

I enabled trace and got this when I did a manual GIF Record:

20:58:51.387	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
20:58:52.225	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	There are 11 open Channels being tracked.
20:58:52.225	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/mjpg/video.cgi?channel=1&subtype=1
20:58:52.225	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/snapshot.cgi?channel=1
20:58:52.226	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/eventManager.cgi?action=attach&codes=[All]
20:58:52.357	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
# ...
20:58:57.401	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
20:58:57.471	DEBUG	org.openhab.binding.ipcamera.internal.IpCameraActions	Recording testapr9.gif for 2 seconds.
20:58:58.358	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
20:58:58.388	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
20:58:59.358	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
20:58:59.358	DEBUG	org.openhab.binding.ipcamera.internal.Ffmpeg	Starting ffmpeg with this command now: -y -r 1 -hide_banner -loglevel warning -i /etc/gifoutput/snapshot%d.jpg -frames:v 7 -r 2 -filter_complex scale=-2:360:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse /etc/gifoutput/testapr9.gif
20:58:59.397	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
20:58:59.404	TRACE	org.openhab.binding.ipcamera.internal.Ffmpeg	[image2 @ 0x562985b2fa80] Could find no file with path '/etc/gifoutput/snapshot%d.jpg' and index in the range 0-4
20:58:59.405	TRACE	org.openhab.binding.ipcamera.internal.Ffmpeg	/etc/gifoutput/snapshot%d.jpg: No such file or directory
20:59:00.226	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	There are 11 open Channels being tracked.
20:59:00.226	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/mjpg/video.cgi?channel=1&subtype=1
20:59:00.226	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/snapshot.cgi?channel=1
20:59:00.226	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/eventManager.cgi?action=attach&codes=[All]
20:59:00.359	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1

When trying the motion-activated GIF recording, I get:

21:36:48.088	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
21:36:48.744	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	HTTP Result back from camera is :--myboundary Content-Type: text/plain Content-Length: 41 Code=VideoMotionInfo;action=State;index=0 :
21:36:48.775	TRACE	org.openhab.binding.ipcamera.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" ] } :
21:36:48.777	ERROR	org.openhab.core.automation.internal.module.handler.AnnotationActionHandler	Could not call method 'public void org.openhab.binding.ipcamera.internal.IpCameraActions.recordGIF(java.lang.String,int)' from module type 'ipcamera.recordGIF#45d20840961e09b4e33263a5c4265a73'.
21:36:49.068	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
21:36:49.093	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
21:36:49.612	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	HTTP Result back from camera is :--myboundary Content-Type: text/plain Content-Length: 41 Code=VideoMotionInfo;action=State;index=0 :
21:36:50.033	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	HTTP Result back from camera is :--myboundary Content-Type: text/plain Content-Length: 41 Code=VideoMotionInfo;action=State;index=0 :
21:36:50.066	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	There are 11 open Channels being tracked.
21:36:50.066	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/mjpg/video.cgi?channel=1&subtype=1
21:36:50.066	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/eventManager.cgi?action=attach&codes=[All]
21:36:50.066	DEBUG	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Open channel to camera is used for URL: /cgi-bin/snapshot.cgi?channel=1
21:36:50.068	TRACE	org.openhab.binding.ipcamera.internal.handler.IpCameraHandler	Sending camera: GET: http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1

First good job on the logs. We’ll see what Matt says.

However, as you begin your OH journey it is helpful to have a few things under your belt. One is the concept of strings (usually in “string”) and integers. Another is that in OH an ERROR means complete failure. I don’t know where you got this ipcamera.recordGIF#45d20840961e09b4e33263a5c4265a73, but it is clearly the problem. In the error message there is this .recordGIF(java.lang.String,int)' That means it is expecting a string and an integer with a parenthesis. As noted above by @sihui. Mine version also seems to work, but could be a quirk of DSL rules. I don’t know if this will work, but you could try ipcamera.recordGIF("#45d20840961e09b4e33263a5c4265a73",2) That will at least correct the one error.

Thanks, Bob.

So, I haven’t actually scripted anything; I’m just using the OpenHAB GUI to make my things and items and channels. When I go to “edit” my items and channels and such, I don’t see that IP camera with a number like that.

When I look in my actual config files on the drive, they are empty.

If anyone could shed some light onto where I can make changes locally and see the entire script, that might be very helpful. Where does the GUI actually save this data that is entered?

You posted a rule? You should be able to edit it

Again, not the most authoritative, I believe the GUI data is saved in the jsondb in the userdata folder (var/lib/openhab/jsondb). The openhab_conf folder is for textually created things, rules, items, etc.

The FFMPEG error is that there are not snapshots in the above location to create the GIF from. So either the binding is not saving them there due to permissions or the snapshots are not able to be fetched from the camera to be stored there.

What happens when you put this URL in any web browser?
http://192.168.0.85:80/cgi-bin/snapshot.cgi?channel=1
Do you get a snapshot from the camera?

Based on the urls is this a Dahua/Amcrest camera?

This was very, very helpful.

I do not see that it is recording snapshots anywhere that I can tell. It is an Amcrest 841 v3. I also installed vstpd onto my Debian machine for FTP from the camera. I still dont get anything at the http://192.168.0.85/cgi-bin/snapshot.cgi?channel=1 site, but:

now when I do a manual GIF recording, I get a GIF of images from a few hours ago. Any idea why that would be? All of my times are synced across my camera, my Debian, and my Windows devices.

MP4 manual recordings capture the current moment, but are still not motion activated either.

Here’s the /etc/gifoutput folder now. It’s after dark here, which the MP4 files recorded from the camera correctly. The gif files and snapshots, even though triggered manually after dark, pulled images somehow from earlier in the day when it was light out.

Then that is the root of the issue. The binding must be able to fetch a snapshot using that URL, or you will need to change the URL to one that does work. As a bad work around, you can enter in ffmpeg in as the snapshot URL and the binding should open up a stream and create snapshots from the stream at the expense of more CPU from the openHAB server and a lower res image…

You need to fix the root cause of the binding not getting a reply back from the camera, and you have confirmed that it happens with a web browser so it is not an issue with the binding but a camera issue.

Do a firmware update and then look at the link I gave above that shows a work around that may explain why it is happening.