IpCamera: New IP Camera Binding

No probs, glad you got it going and enjoy the binding.

It should be possible, but it needs you to have a play and understand the trade offs. Having a camera that allows keyframes every second (or even more often as some cameras allow you to specify how often, some even allow every second frame) will help the most, you will also need to keep the stream running non stop.

The binding has to work on as many browsers as possible with default settings, as many cameras with their default settings and also support working on demand for those that donā€™t want it running all the time. Compromises are made to allow it to work in a wide range of situations so if you play you can tailor it to what you want as you have direct access to the ffmpeg command.

It can actually be useful, if your TV takes time to turn on and switch inputs you still get to see the person at your door instead of their backs as they walk away :slight_smile:
I use the cameras as a baby monitor so I really donā€™t care about a delay, each person uses cameras for different things.

I personally do the following and it works great here on a Google/Nest hub.

  1. Cast the ipcamera.jpg the moment the doorbell is pushed and also trigger the GIF. The binding can send a jpg faster than your camera, as some cameras need to wait for a keyframe to be created first which may be 2 seconds away.
  2. When gif is ready, cast it and it can include preroll time that shows the person walking up to the door and pushing the button (pretty cool as the button is the trigger) and it can be in 2x 4x or any speed you wish to see it fast forward and loop.
  3. You could get fancy and show a history of the days visitors with the gif file. I have it sent to me with pushover which makes a different noise to email on my phone.

Plenty of ways to automate.

I installed the latest update, removed cache and temp and did a server reboot, but now my gif-file is very small and the resolution of the gif is only 202x360 pixel. Before the update with the exact same settings, my gif file was much bigger in size and resolution.

How can i bring back my old gif-size? On 202x360 i nearly can see nothingā€¦

Iā€™m guessing you have your camera rotated, I would recommend you make the 480 in the below be a even devision of what your cameras resolution is. Half or quarter of the pixels, for example for 1920 pixels the 480 is a good choice as it is 1920 / 4.

Try this for 2 times speed.

FFMPEG_GIF_OUT_ARGUMENTS="-r 2 -filter_complex scale=480:-2:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse"

Try this for 4 times speed.

FFMPEG_GIF_OUT_ARGUMENTS="-r 4 -filter_complex scale=480:-2:flags=lanczos,setpts=0.25*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse"
1 Like

Thanks, now i have 480x854 pixels

Dont mind having the stream running non stop.
But IĀ“m not sure how to find the info of the camera keyframes. Its not listed anywhere. Second I believe I will run into problems with the cam. ItĀ“s a 4Mb pixel cam having two streams, unfortunatly there isnt many different resolutions to choose between. That may become a huge problem.

Thats why its of no use to use a TV :smiley:
Can the Google Nest Hub show the animated Gif? (I havnĀ“t had time to test it). This could be an option then.

@matt1
Did you change anything else in the FFMPEG_GIF_OUT_ARGUMENTS in the new binding version? Because my gif looks in another way as with the old binding versionā€¦ The picture quality is worse compared to the former version. But the size of the gif-file is even bigger.

Can you give me the exact arguments which were used in the old binding (when i didnĀ“t write extra arguments to the things-file)?

Well I played around with the ffmpeg params a bit. Adding these:

-hls_time 1 -hls_allow_cache 0 -hls_list_size 3

I now get about 5s delay. Still not perfect, but much better than before. I am not entirely sure that list size makes any difference though. The caching is just something I added to discourage devices from caching anything - they probably shouldnā€™t anyways, but just to be safe.

Of course my cameras are set to produce a keyframe every second (they were all along).

To be honest I am seriously thinking of returning back to the old days - using an external server to generate mjpeg. Using the pure RTSP stream in full resolution the delay is less than 1s - which is ideally what I want. And with a server generating mjpeg it wasnā€™t that far off. The only thing that I hate about that is that I have to manage another script on a different server that will do that. And when that script fails it needs to be started again, ā€¦

How do you change keyframe?

Mine has a setting for that.
ā€œI frame intervalā€

Okay guess I need new cam

That is a good idea as mjpeg can handle network stress without needing a buffer. I am working on being able to cast the mjpeg streams but so far I am missing something that chromescast wants so I need a capture of a working stream to compare against.

We all have different requirements and mine is I need sound to hear the baby cry and mjpeg is picture only. I mostly use mjpeg here.

My problem is that I canā€™t get mjpeg out of the cameras (except for the second stream which is in a useless resolution) which sucks. And running an external server is a pain. Iā€™ll look into moving my home automation server onto that server instead. That would at least mean that I have one less thing to manage.

My requirement is basically to have real time feeds from 6 of the cameras (different 6 on different tablets) on a wall mounted tablet. So that I can quickly glance at the screen when I am at home and see what is going on around the house.

Have you tried the snapshots.mjpeg stream the binding creates yet? you can display it on tablets and it is high res if the snapshot comes from your mainstream.

Yes, I have tried it. I posted about it a few days ago. Using it switches my cameras secondary stream to MJPEG and it is low res and extremely low framerate. Even setting it to update once per second still takes about 2s. And I would like at least 5-10 fps.

My requirements isnĀ“t (shouldnĀ“t be) really that bad.
I want ipcams to show, (as close as possible to realtime), on my Google Nest Hub (or other chomecast devices) on request, as well as on movement. (For doorbell as well as surveillance).
Thats my main goalā€¦

I honestly fail to understand, howcome rtsp isnĀ“t possible, but I guess thats a Google decision. I wonder how the Nest Doorbell is working. I doubt it has any where near the same kind of delay, perhaps 1-2 second at most.
Yesterday I watched a movie on Youtube about a streaming service for the Rpiā€¦ He is streaming 4 cams using rtsp at the same timeā€¦There is a very short delay, but itĀ“s close to 1 seconds.

I know, rtsp isnĀ“t the same as HLS or MJPEG. But I fail to understand, when there is a standard realtime streaming protocolā€¦ how come itĀ“s not the first choice forā€¦ streaming!!
Its like building something using rocketsience, which isnĀ“t really needed, cause itĀ“s already build.

I probably have one major issueā€¦
IĀ“ve got a very good ipcamera, (Reolink RCL 410). But itĀ“s bad for the purpose, as it cant do MJPEG, and it has two streams. One very high, and a second very low.

    Video
    Compression     H.264

    Resolution
    Mainstream: 2560x1440, 2048x1536, 2304x1296, 1080p, 720p; Substream: 640x360

    Bitrate
    Mainstream: 1024Kbps~8192Kbps; Substream: 64Kbps~512Kbps

    Frame Rate
    Mainstream@25fps, Substream@6fps

(The Mainstream resolution 1080p and 720p is NOT available in my 4MP version running the latest firmware. Substream fps can go to 12fps).
I cant change keyframe.

I think I will order a couple of Dahau IPC-HDBW4433R-S insted, which I hope will do alot better. At least they can do MJPEG and they have more options for streams. But IĀ“m not sure about the keyframe. Its specs says ā€œI Frame 25-150ā€ Whatever that mean. And IĀ“m not sure if this will do for my wishes.

Hi ,

i have a question/ issue pls, can i post this here?
First offā€¦ i am a beginner lvl in openhab so if you see stupid stuff, thats why. :smiley:

My goal for now is to get a live view working (i think via API) but my sitemap disappears with the options i tested.

Explanation:
I did not get my cameras working back in the day with this binding when i gave up :slight_smile:

So, now, i just removed my 2.3 snapshot of the binding and installed the 2.5 to try again.
I notice Axis is no longer an option? What is the alternative you advise or something i need to know, cant find anything special about it in the docs.

Butā€¦
After installing the new binding my camera was found automatically as a thing via ONVIF with a lot of available actions.
I did have to add the snapshot URL to get this camera ā€œonlineā€

Then i manually made an item in Home.items and linked it to the MJPEG option of my camera thing.
Hoping to just add a sitemap item and done.

In your documentation i see this example in the items, but i think i dont see you using this item in your sitemap:

String BabyCamStreamUrl "Mjpeg Stream" { channel="ipcamera:DAHUA:BabyCamera:streamUrl" }

How could i get a live view pls?
I think i see how you live view on the bottom of the sitemap example, but it has nothing to do with the binding right?:

Text label="Cameras Mjpeg Stream" icon="camera"{Video url="http://192.168.0.2:54321/ipcamera.mjpeg" encoding="mjpeg"}

Anywayā€¦ Hereā€™s what i have/ tried:
my item i added:

    String Mjpegurl "Oprit Cam mjpeg" { channel="ipcamera:ONVIF:Camera1:streamUrl" }

My sitemap disappears via basicui when using (in sitemap):

String item=Mjpegurl

or

Video item=Mjpegurl

or its just stays empty in my category (but sitemap works) when using:

Image item=Mjpegurl

Config:
RPI 3/ openhab 2.5 / ipcamera binding 2.5
Axis m3204 with API and ONVIF.

And beside the live view questionā€¦ my next question, i thought i was going to be able to choose Axis and API from the list, is this still possible?
Dunno if i would actually want to use ONVIF.

up untill now i just did it without the bindingā€¦ but only liveview tho, by adding 1 lline in my sitemap:

Webview url="http://192.168.1.252/axis-cgi/mjpg/video.cgi?resolution=1024x768" icon=none height=22

thats why i started testing with mjpeg :slight_smile:
But was looking for API.

Thx in advance :slight_smile:

Sorry for the long post!
Feels so rude to just put my code here and just ask ā€œwhats wrongā€, without the story.
And to be as complete as possible. :slight_smile:

sneaky adding @matt1, heard from H102 that you are ā€œthe camera guruā€.

Yes just set it up as a ONVIF thing type. The API for axis is not implemented.

That should not happen, possibly you had the onvif port set wrong and it could not ask the camera for this URL.

That is a useful way to give the item to a habpanel element, this way if you change the user/pass you donā€™t have to do a find and replace on multiple files. It is probably better to use the cameras url directly in your case, however there are times like trying to cast the cameras jpg file, you probably will find it works through the binding but not direct from the cameras own url.

Can you tell me which part of the readme needs updating to be more clear? I will be happy to update and take feedback to improve it.

That is a good way to do it.

Looks fine here with the newer format and the size increase is due to more of the snapshots are used, previously it was missing some.

I think this was what was usedā€¦

-filter_complex fps=2,scale=480:-2:flags=lanczos,setpts=0.5*PTS,split[o1][o2];[o1]palettegen[p];[o2]fifo[o3];[o3][p]paletteuse

@matt1
Thank you for the reply!

tried researching a bit more, the only thing needed for my camera (as far as i can see!) is a onvif user account, which i have created.
I opened my onvif device manager software, it connects without an issue but i can not seem to find over what port, i did not define anything and can not choose whether i would like to connect over another port, so i think this is port 80.
Did not find anything about a port for ONVIF either in the manual.

my camera gives this error in the paper UI thing (without snapshot override filled in):

Status: OFFLINE - CONFIGURATION_ERROR Camera failed to report a valid Snaphot URL, try over-riding the Snapshot URL auto detection by entering a known URL.

I think that is indeed a good idea.

Its probally me tho, i just thought that when i did see an item in the items file, that i could now just use a sitemap entry, using this same name from the items file, to get the liveview up and running, this one basically :"BabyCamStreamUrl "
So therefore i was searching through the sitemap. :slight_smile:

up untill now i just did it without the bindingā€¦ but only liveview tho, by adding 1 lline in my sitemap:

2 days ago i learned about a ā€œwebviewā€ option,

Webview url="http://192.168.1.252/axis-cgi/mjpg/video.cgi?resolution=320x240" icon=none height=10'

once i started using thisā€¦ i could see my cameraā€™s in my android app as well

Compaired to before with image, it only worked via basic UI.:

Image url="http://192.168.1.252/axis-cgi/mjpg/video.cgi"

Its only cause it worked so well, i though let me play around with the binding once more.
Thing is that when using webview, the android app does not show cameraā€™s when my mobile is on 4g, so not beeing home, it looks in the app for a ā€œlocalā€ IP

hoped the binding could maybe fix this, its like my openhab android app doesnt go to my RPI first for this URL, but tries to get it locally.

1 Like

The readme has multiple examples of how to get a picture and stream working, paste them in from the full example and give them all a go. The WebView will not work through myopenhab, so you can use OpenVPN or WireGuard VPN if you prefer that way so that you show up on your local network when not at home, or choose another way of displaying the stream. I recommend looking at the autofps.mjpeg method when you are connected on 4g. If you setup as httponly thing type you can then use the ffmpeg motion alarm to change the framerate based on if motion is detected or not.