This binding allows you to use most IP cameras in openHAB and has many hidden features, so please take the time to read through this guide to learn different ways to work with cameras that you may not know about.
I recommend purchasing a brand of camera that has an open API, as many features use far less CPU when done with an API camera.
They usually have better picture quality and more advanced features compared to lower priced cameras.
To see what features each brand has implemented from their APIs, please see this post:
This binding can turn a RTSP stream into snapshots (.jpg still pictures), create motion and audio alarms, cast the camera and much more.
FFmpeg is required to be installed for these features to work and this must be done manually.
FFmpeg can be installed very easily see [Video Streams](#video-streams).
If your camera has a snapshot URL, provide it to the binding via the config called `snapshotUrl` after first testing the URL in any browser.
When using FFmpeg instead of a provided URL to create snapshots, it requires more CPU that you can turn on and off via the `pollImage` channel using a switch or rule.
Snapshots generated by FFmpeg use the key frames (iFrames) to lower the CPU load, and since some cameras only produce a key frame every 2+ seconds with their default settings, this will effect how often a snapshot is produced.
Some cameras allow the key frame to be created every second or a different amount by the user, refer to your cameras manual and support on how to do this.
### ESP32 Cameras
These cameras do not have the ability to create H.264 streams and hence can not be used with HLS, however all other features should work.
Due to many custom firmwares available, you may need to ask the firmware developer what the URLs are for snapshots and MJPEG streams if they have changed the defaults from what the Arduino IDE sample code uses.
Another limitation is that they can only provide a single stream at a time, so you need to setup the `ffmpegInput` to use the ipcamera.mjpeg feed from the openHAB server and change `ffmpegInputOptions` to "-f mjpeg" so FFmpeg knows the input is MJPEG format and not H.264.
For MJPEG to work, you need to set the first sub-stream to use MJPEG format for the default settings to work, otherwise you can override the default with `mjpegUrl` config with a valid URL for MJPEG streams.
- If the user/pass is wrong, the camera can lockout and refuse to answer the binding requiring a reboot of the camera, so be sure the details are correct before the camera tries to poll the camera too many times.
- To use MJPEG streaming, you need to enable one of the streams to use this format. This can be done by entering this into any browser:`http://ip:88/cgi-bin/CGIProxy.fcgi?cmd=setSubStreamFormat&format=1&usr=admin&pwd=password`
- If your camera does not support MJPEG as some Foscams no longer do, then you can set `mjpegUrl` to contain _ffmpeg_ to use your CPU to generate a MJPEG stream.
- Some Foscam cameras need to have a detection area listed in the URL when you enable the motion alarm.
As each Foscam model has a different resolution and two different URLs, this makes it difficult to automate, so an override feature was added to create your own "enable the alarm" URL.
This setting is called `customMotionAlarmUrl` and the steps to using it are:
1. Enable the motion alarm in the web interface of your camera and setup any areas you wish movement to be ignored in. E.g. tree branches moving in the wind.
- For MJPEG to work, you need to set the first sub-stream to be in MJPEG format, otherwise you can override the default with the `mjpegUrl` config with a valid URL for MJPEG streams.
- The CGI/API and also ONVIF features are disabled by default on these cameras, so enable and create user details for ONVIF that are the same user/pass as what you have given the binding.
- ONVIF is enabled and a user/pass created that match the bindings.
- RTSP is enabled.
- Some NVR's allow each camera to be exposed on a set port to give direct access to each camera, some users report this works the best and needs to be enabled.
- For MJPEG to work, you need to set the first sub-stream to be MJPEG format for the default settings to work, otherwise you can override the default with mjpegUrl with a valid URL for MJPEG streams.
- Be sure to update to the latest firmware for your camera as Instar have made a lot of improvements recently, including adding MQTT features (MQTT is not needed for this binding to work).
- NVR's made by Reolink have ONVIF disabled by default and may require a screen connected to the hardware to enable ONVIF, or newer firmwares may be able to do this via their app or web UI.
- This binding will use the Reolink API for polling the alarms if the `nvrChannel` is 1 or higher and does not need ONVIF to be enabled. To use ONVIF event methods for the alarms, you can set `nvrChannel` to 0.
- Cameras have ONVIF, RTSP and HTTP disabled by default, to enable these required features, do the following: DEVICE SETTINGS>NETWORK>ADVANCED>PORT SETTINGS> then turn these on leaving the default port number alone.
- Consider setting the substream of the camera to be 4 FPS and to 640*360 as this will lower CPU load if using the ipcamera.mjpeg stream.
This method should be preferred as it will discover the cameras IP, ports and URLs for you, making the setup much easier.
The binding needs to use UDP port 3702 to discover the cameras with, so this port needs to be unblocked by your firewall or add the camera manually if the camera is not auto found.
If using openHAB's textual configuration, or when needing to setup HABpanel/sitemaps, you may need to know what your camera is as a "thing type".
Example: The thing type for a camera with no ONVIF support is "generic".
| Thing Type ID | Description |
|-|-|
| `generic` | For any camera that is not ONVIF compatible, yet has working RTSP or HTTP URLs. |
| `onvif` | Use for all ONVIF cameras that do not have an API. |
| `amcrest` | Only use for if your Amcrest cameras wont work as a `dahua` thing. This uses an older polling based method for alarms that is not as efficient as the newer method used in `dahua`. Amcrest are made by Dahua and hence the API is similar. |
| `dahua` | Use for all Dahua and Amcrest cameras that support the API. |
| `doorbird` | Use for all current Doorbird cameras as they support an API as well as ONVIF. |
| `foscam` | Use for all current Foscam HD cameras as they support an API as well as ONVIF. |
| `hikvision` | Use for all current Hikvision cameras as they support an API as well as ONVIF. |
| `instar` | Use for all current Instar cameras as they support an API as well as ONVIF. |
| `group` | Used to display or cast multiple cameras like they are a single camera. This is an advanced feature that may require some tweaking of the cameras settings to fully work. |
If your camera is not ONVIF/API based, you will also need to provide the binding with the cameras URLs to the relevant config field/s.
For ONVIF cameras that auto detect the wrong URL, these same fields can be used to force a URL of your choosing but leaving them blank will allow the binding to find the URL for you.
NOTE: Leave any `user:pass@` out of any URLs, the binding will handle this for you.
Not only does this hide your login details, it will also make changing your password much easier if it is only located in 1 field.
| `onvifPort`| The port your camera uses for ONVIF connections. This is needed for PTZ movement, events, and the auto discovery of RTSP and snapshot URLs. A value of 0 will prevent the binding from trying to connect to ONVIF. |
| `username`| Leave blank if your camera does not use login details. |
| `password`| Leave blank if your camera does not use login details. |
| `onvifMediaProfile`| 0 (default) is your cameras Mainstream and the numbers above 0 are the substreams. Any auto discovered URLs will use the streams that this indicates. You can always override the URLs should you wish to use something different for one of them. |
| `pollTime`| Time in milliseconds between fetching a JPG. Note: Most features will not poll non stop and are done "on demand" to keep network traffic to a minimum. The exception is when using the GIF preroll feature, this will cause the camera to always fetch a snapshot every poll. |
| `updateImageWhen`| The `Image` channel can be set to update in a number of ways to help reduce network traffic. Recommend that you DO NOT USE the image channel unless you use a very large pollTime. |
| | `0` - Default and the RECOMMENDED setting, the Image channel never updates. |
| | `1` - Update the Image channel only when the `pollImage` channel is turned on.|
| | `2` - Start of Motion Alarms will update the Image channel. |
| | `3` - Start of Audio Alarm will update the Image channel. |
| | `23` - Start of Motion and Audio Alarms will update the Image channel. |
| | `4` - During Motion Alarm the Image channel will update every poll until Alarm stops. |
| | `5` - During Audio Alarm the Image channel will update every poll until Alarm stops. |
| | `45` - During Motion and Audio Alarms the Image channel will update every poll until both alarms stop. |
| `nvrChannel`| Set this to `1` (default) if it is a standalone camera, or to the input channel number of your NVR that the camera is connected to. This effects the hard coded URLs for the API based cameras. |
| `snapshotUrl`| Leave this empty to auto detect the snapshot URL if the camera has ONVIF, or enter a HTTP address if you wish to override with a different address. Setting this to `ffmpeg` forces the camera to use FFmpeg to create the snapshots from the RTSP stream. |
| `alarmInputUrl` | A URL you can use for the FFmpeg created Audio and Motion Alarms as they don't require high res feeds as they are not seen. |
| `customMotionAlarmUrl`| Foscam only, for custom enable motion alarm use. More info found in Foscam's setup steps. |
| `customAudioAlarmUrl`| Foscam only, for custom enable audio alarm use. More info found in Foscam's setup steps. |
| `ffmpegInput`| Best if this stream is in H.264 format and can be RTSP or HTTP URLs. Leave this blank to use the auto detected RTSP address for ONVIF cameras. |
| `ffmpegInputOptions` | Allows you to specify any options before the -i on the commands for FFmpeg. If you have an ESP32 camera that only has a mjpeg stream then make this equal `-f mjpeg`. |
| `ffmpegLocation`| The full path including the filename for where you have installed FFmpeg. The default should work for most Linux installs but if using windows use this format: `c:\ffmpeg\bin\ffmpeg.exe` |
| `ffmpegOutput`| The full path to a unique folder (different for each camera) where FFmpeg has the ability to write files to ending with a slash. If you leave this blank, the binding will automatically use `$OPENHAB_USERDATA/ipcamera/UID`. See here for where this is located on your installation, <https://www.openhab.org/docs/installation/#getting-installation-info> |
| `hlsOutOptions`| This gives you direct access to specify your own FFmpeg options to be used. Default: `-strict -2 -f lavfi -i aevalsrc=0 -acodec aac -vcodec copy -hls_flags delete_segments -hls_time 2 -hls_list_size 4` |
| `gifOutOptions`| This gives you direct access to specify your own FFmpeg options to be used for animated GIF files. Default: `-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` |
| `mjpegOptions` | Allows you to change the settings for creating a MJPEG stream from RTSP using FFmpeg. Possible reasons to change this would be to rotate or re-scale the picture from the camera, change the JPG compression for better quality or the FPS rate. |
| `motionOptions` | This gives access to the FFmpeg parameters for detecting motion alarms from a RTSP stream. One possible use for this is to use the CROP feature to ignore any trees that move in the wind or a timecode stamp. Crop will not remove the trees from your picture, it only ignores the movement of the tree. |
| `gifPreroll`| Store this many snapshots from BEFORE you trigger a GIF creation. Default: `0` will not use snapshots and will instead use a realtime stream from the ffmpegInput URL |
| `ipWhitelist`| Enter any IPs inside brackets that you wish to allow to access the video stream. `DISABLE` the default value will turn this feature off. Example: `ipWhitelist="(127.0.0.1)(192.168.0.99)"` |
| `ptzContinuous`| If set to false (default) the camera will move using Relative commands, If set to true the camera will instead use continuous movements and will require an `OFF` command to stop the movement. |
| `onvifEventServiceType`| ONVIF event method to use. If camera does not report event capabilities, the event method can be forced here. |
| | `0` - Auto detect event capabilities. (Default) ONVIF event capabilities are detected automatically. PullMessages is prefered over WSBaseNotification because there is no way to determine if an WSBaseNotification subscription exists on startup. |
| | `1` - ONVIF events disabled. |
| | `2` - Force ONVIF PullMessages event method even if the camera does not claim to support this. |
| | `3` - Force ONVIF WSBaseSubscription event method even if the camera does not claim to support this. |
| `animalAlarm` | Switch | RW | Toggles when an animal is in view. |
| `audioAlarm` | Switch | R | When the camera detects noise above a threshold this switch will move to ON. |
| `autoLED` | Switch | RW | When ON this sets a cameras IR LED to automatically turn on or off. |
| `autoTracking` | Switch | RW | Turn the automatic mode for tracking ON or OFF. |
| `autoWhiteLED` | Switch | RW | When ON this sets a cameras visible white LED to automatically turn on or off. |
| `carAlarm` | Switch | RW | When a car is detected the switch will turn ON. |
| `cellMotionAlarm` | Switch | R | ONVIF cameras only will reflect the status of the ONVIF event of the same name. |
| `doorBell` | Switch | R | Doorbird only, will reflect the status of the doorbell button. |
| `enableAudioAlarm` | Switch | RW | Allows the audio alarm to be turned ON or OFF. |
| `enableEmail` | Switch | RW | Allows the email features to be turned ON or OFF. |
| `enableExternalAlarmInput` | Switch | RW | Hikvision and Instar allow the Alarm input terminals to be disabled by this control. |
| `enableFieldDetectionAlarm` | Switch | RW | Allows the field detection alarm to be turned ON or OFF. Some cameras will call this the Intrusion Alarm. |
| `enableFTP` | Switch | RW | Turn the cameras internal FTP recordings ON or OFF. |
| `enableLED` | Switch | RW | Turn the IR LED ON or OFF. Some cameras have 3 states the LED can be in, so see the `autoLED` channel. |
| `enableLineCrossingAlarm` | Switch | RW | Turns the line crossing alarm for API cameras, ON and OFF. |
| `enableMotionAlarm` | Switch | RW | Turns the motion alarm ON and OFF for API cameras. This will not effect FFmpeg based alarms which have their own control. |
| `enablePirAlarm` | Switch | RW | Turn PIR sensor ON or OFF. |
| `enablePush` | Switch | RW | Allows the push notification features to be turned ON or OFF. |
| `enableRecordings` | Switch | RW | Turn the cameras internal recordings ON or OFF. |
| `externalAlarmInput` | Switch | R | Reflects the status of the alarm input terminals on some cameras. |
| `externalAlarmInput2` | Switch | R | Reflects the status of the alarm input 2 terminals on some cameras. |
| `externalLight` | Switch | RW | Some cameras have a dedicated relay output for turning lights on and off with. |
| `externalMotion` | Switch | RW | Can be used to inform the camera if it has motion in its view area. Handy if you own a PIR or any other kind of external sensor. If you use the autofps.mjpeg feature, this could increase the frame rate when a door that was closed is opened. Note: It will not be passed onto your camera and will not trigger any recordings. |
| `faceDetected` | Switch | R | When a camera detects a face (API cameras only) this switch will move to ON. |
| `fieldDetectionAlarm` | Switch | R | Reflects the cameras status for the field or intrusion alarm. |
| `ffmpegMotionAlarm` | Switch | R | The status of the FFmpeg based motion alarm. |
| `ffmpegMotionControl` | Dimmer | RW | This control allows FFmpeg to detect movement from a RTSP or HTTP source and inform openHAB. The channel that will move is called `ffmpegMotionAlarm`. |
| `gifHistory` | String | RW | The 50 most recent filenames the binding has used unless reset. |
| `gifHistoryLength` | Number | RW | How many filenames are in the `gifHistory`. |
| `gotoPreset` | String | RW | ONVIF cameras that can move only. Will cause the camera to move to a preset location. |
| `hlsUrl` | String | RW | The URL for the ipcamera.m3u8 file. |
| `humanAlarm` | Switch | RW | When a camera detects a human this switch will turn ON. |
| `imageUrl` | String | RW | The URL for the ipcamera.jpg file. |
| `itemLeft` | Switch | R | Will turn ON if an API camera detects an item has been left behind. |
| `itemTaken` | Switch | R | Will turn ON if an API camera detects an item has been stolen. |
| `lastMotionType` | String | RW | Cameras with multiple alarm types will update this with which alarm last detected motion, i.e. a lineCrossing, faceDetection or item stolen alarm. You can also use this to create a timestamp of when the last motion was detected by creating a rule when this channel changes. |
| `lastEventData` | String | RW | Detailed information about the last smart alarm that can contain information like which Line number was crossed and in which direction. The channel `lastMotionType` will hold the name of the alarm that this data belongs to. |
| `lineCrossingAlarm` | Switch | R | Will turn on if the API camera detects motion has crossed a line. |
| `mjpegUrl` | String | RW | The URL for the ipcamera.mjpeg stream. |
| `motionAlarm` | Switch | R | The status of the 'video motion' events in ONVIF and API cameras. Also see `cellMotionAlarm` as these can give different results. |
| `mp4History` | String | RW | The 50 most recent filenames the binding has used unless reset. |
| `mp4HistoryLength` | Number | RW | How many filenames are in the `mp4History`. Setting this to 0 will clear the history. |
| `pan` | Dimmer | RW | Works with ONVIF cameras that can be moved. |
| `parkingAlarm` | Switch | R | When an API camera detects a car, this will turn ON. |
| `pirAlarm` | Switch | R | When a camera with PIR ability detects motion, this turns ON. |
| `privacyMode` | Switch | RW | Enable or disable the Privacy Mode of newer Amcrest/Dahua cameras. The camera will move the lens way down and stop the stream. |
| `recordingGif` | Number | R | How many seconds recording to GIF for. 0 when file ready. |
| `recordingMp4` | Number | R | How many seconds recording to MP4 for. 0 when file ready. |
| `rtspUrl` | String | RW | The URL for the cameras auto detected RTSP stream. |
| `sceneChangeAlarm` | Switch | R | When an API camera detects the camera has moved, this turns ON. |
| `startStream` | Switch | RW | Starts the HLS files being created, if it not manually moved it will indicate if the files are being created on demand. |
| `storageAlarm` | Switch | R | When an ONVIF cameras storage is full and/or removed, this turns ON. |
| `tamperAlarm` | Switch | R | When an ONVIF cameras tamper switch is tripped, this turns ON. |
| `textOverlay` | String | RW | Dahua, Instar and Hikvision can overlay any text you enter here over the video stream. |
| `thresholdAudioAlarm` | Dimmer | RW | This channel can be linked to a Switch and a Slider. The value of the slider is the value in dB that is detected as noise/alarm down from digital full scale. Higher values are more sensitive and will trigger the alarm with quieter / less noise. |
| `tilt` | Dimmer | RW | Works with ONVIF cameras that can be moved. |
| `triggerExternalAlarmInput` | Switch | RW | Hikvision cameras can change if the alarm input terminal is ON when high or low. This can be used to manually cause an alarm input event to occur. |
| `tooBlurryAlarm` | Switch | R | ONVIF cameras only will reflect the status of the ONVIF event of the same name. |
| `tooBrightAlarm` | Switch | R | ONVIF cameras only will reflect the status of the ONVIF event of the same name. |
| `tooDarkAlarm` | Switch | R | ONVIF cameras only will reflect the status of the ONVIF event of the same name. |
| `pollImage` | Switch | RW | This control can be used to manually start and stop using your CPU to create snapshots from a RTSP source. If you have a snapshot URL setup in the binding, only then can this control can be used to update the Image channel. |
| `whiteLED` | Dimmer | RW | Turn the visible white LED ON or OFF and if supported dim from 0-100%. |
| `zoom` | Dimmer | RW | Works with ONVIF cameras that can be moved. |
| `acceptedCardNumber` | String | R | This channel shows the last accepted access card number that opened the door. The channel doesn't show rejected/unauthorized cards. |
| `unacceptedCardNumber` | String | R | This channel shows the last unaccepted access card number that was read. |
| `doorUnlock` | Switch | RW | This channel could reflect door lock state and at the same time send commands to door lock. Note that under some conditions doorphone doesn't send "lock off" message, so it's better to add expiration timer to corresponding item. |
| `doorContact` | Contact | R | Reflects door open/closed contact state. |
| `exitButton` | Switch | R | Reflects exit button state. This could be used to check for exit button's long clicks/double clicks, so the button could control other gates connected to openHAB, or outdoor lights. |
| `exitButtonEnabled` | Switch | RW | This channel could be used to disable the exit button to provide additional security at night or when noone is home. |
To test your cameras compatibility and also to create some preset locations, use a free program called `ONVIF Device Manager` (ODM for short).
Not all ONVIF cameras work with all of the methods, so testing first to confirm what works is a good idea and the presets can not be created with the binding, only loaded after they are already created in a program like ODM.
After creating new or changing existing presets, it is necessary to send the REFRESH command to the `gotoPreset` channel or you can restart the binding if that is easier.
Moving the camera using _Relative_ or _Continuous_ (config `ptzContinuous` must be true) movements can be done by sending the INCREASE and DECREASE commands to the Pan, Tilt and Zoom channels.
There are some widgets created in the HABpanel widget gallery that you can download and use right away saving you time if your camera supports either presets, relative or continuous modes.
Moving the camera to an EXACT repeatable location (Preset 1 saved location) with a rule:
```java
BabyCamGotoPreset.sendCommand(1)
```
Moving the camera to an EXACT repeatable location using Absolute movement with a rule:
```java
BabyCamPan.sendCommand(22)
BabyCamTilt.sendCommand(60)
BabyCamZoom.sendCommand(0)
```
## FFmpeg Motion and Audio Alarms
Any camera can use FFmpeg to create either a `ffmpegMotionAlarm` or `audioAlarm`.
Before using this feature, consider if the <https://www.openhab.org/addons/bindings/ftpupload/> is better used if your camera can upload to a FTP (binding can creates a virtual FTP so you don't need one).
A Zwave or Zigbee PIR sensor is another way to save the CPU load this feature creates.
Even if your camera has a motion alarm, you may find that it does not provide enough flexibility to ignore moving trees, or have its sensitivity adjusted on the fly to reduce its sensitivity during rain.
This is where this feature can come in handy, as you can add any of the many FFmpeg filters like crop as this wont effect the video feeds you watch.
- Provide a URL to the bindings config `alarmInputUrl` or leave it blank to use the auto detected URL if your camera has ONVIF.
- Install FFmpeg.
- You have the resolution and FPS at realistic settings for your CPU. You need to reach 1.x speed otherwise the alarm will lag further behind realtime the longer you have this running.
- The output of the alarm will go to a channel called `ffmpegMotionAlarm` and you can use the `lastMotionType` channel to determine which alarm was last tripped if your camera has multiple alarm types.
If you setup a lower resolution URL in the config `alarmInputUrl` you need to ensure it contains audio otherwise this feature wont work.
A value of 10 on a slider translates to -10dB below max volume (digital full scale) and when the audio goes above the -10dB threshold the alarm will turn ON.
## Image / Snapshots
There are a number of ways to use snapshots with this binding.
The binding has its own file server that works by allowing access to the snapshot and video streams with no user/password for requests that come from an IP located in the `ipWhitelist`.
Requests from external IPs or internal requests that are not on the `ipWhitelist` will fail to get any answer.
If you prefer to use your own firewall instead, you can also choose to make the `ipWhitelist` equal "DISABLE" and then all internal IPs will have access.
There are multiple ways to get a moving picture, to use them just enter the URL into any browser using `http://openHAB:8080/ipcamera/{cameraUID}/name.format` replacing the name.format with one of the options that are listed below:
A lot of cameras limit the resolution in this format, so consider using HLS, autofps.mjpeg, or snapshots.mjpeg instead which will be in a higher resolution.
You can also use the `externalMotion` channel to change the framerate.
This feature is designed to keep data traffic to your mobile devices as low as possible by automatically sending 1fps when motion is occurring, but only 1 picture every 8 seconds when the picture has no motion.
The idea is to not send lots of pictures if the picture has not changed as doing so only eats up your data plan.
Cameras that have built in MJPEG abilities can stream to openHAB with the MJPEG format with next to no CPU load, less than 1 second lag, and FFmpeg does not need to be installed.
Cameras without this ability can still use this binding to convert their RTSP H.264 format to MJPEG (keep reading for more on this below) and this may use a lot of CPU power to handle the conversion.
The lower the resolution of the stream, the lower the CPU load, so consider using a substream of the camera in the `mjpegUrl` configuration field.
The alternative is to use HLS format which does not need the conversion and does not use any CPU to speak of.
For video without a delay, you need MJPEG and without a camera that can create it, you will need to use a lot of CPU power.
This can be done in a dedicated video server which will be the only way with lots of cameras, unless you purchase cameras that have the ability built in.
An alternative way to keep the CPU load low is to use the `snapshots.mjpeg` or `autofps.mjpeg` feature of the binding to create a stream from the cameras snapshots instead of the RTSP stream.
To request the MJPEG stream from the binding, all you need to do is use this link changing the IP to that of your openHAB server and the uniqueID of the camera.
To use this feature, all you need to do is set the config `mjpegUrl` to contain "ffmpeg" to use your CPU to generate the MJPEG stream with FFmpeg.
For cameras that have an API you can opt to not use the cameras stream and use FFmpeg instead should you run out of available streams.
FFmpeg may require you to lower the resolution and/or the FPS to lower the CPU load down enough to run, you may need to experiment.
To change the settings used by this feature the binding exposes the config `mjpegOptions` which the default is currently `-q:v 5 -r 2 -vf scale=640:-2 -update 1` where 5 is the JPG quality/compression setting, and -r 2 is how many frames per second to try and create.
`-vf scale=640:-2` will lower the resolution down to make the video 640 pixels wide.
You can remove this to use the same resolution as the camera is set to use, however it may become a trade off and you may get less frames per second if you raise the resolution.
Always try to get the default settings working first before you begin to experiment and if your stream is above 1080p and 10 frames per second, consider lowering it if you have issues on an ARM based server like a Raspberry PIx.
These similar features allow you to request a MJPEG stream created by the binding with low CPU usage from the cameras snapshots.
Snapshots are usually high resolution and look great, however they are limited to a max of 1 frame per second (1 FPS).
The reason this is more useful than snapshots on their own, is some UIs will flash white or black when a snapshot is refreshing, this does not happen with snapshots.mjpeg and is the same bandwidth and CPU load as just using snapshots!
The autofps.mjpeg feature will display a snapshot that updates every 8 seconds to keep network traffic low, then when motion is detected it will automatically increase the frames to every second until the motion stops.
HLS is a way of splitting the live stream up into small H.264 based files so it can be played in many browsers (some require addons to be installed) without using much CPU power as cameras generally are already in H.264 and this does not transcode the data.
The startup delay and the lag are two different things, with the startup delay easily solved by turning this channel ON.
If the channel is OFF, the stream will start and stop automatically as required and the channel will reflect its current status.
With a fast openHAB server it should only need to be requested once, but on slower ARM systems it takes a while for FFmpeg to get up and running at full speed.
It can be helpful sometimes to use this line in a rule to start the stream before it is needed further on in the rule `sendHttpGetRequest("http://openHAB:8080/ipcamera/{cameraUID}/ipcamera.m3u8")` as the stream will stay running for 64 seconds.
This 64 second delay before the stream is stopped helps when you are moving back and forth in a UI, as the stream does not keep stopping and needing to start each time you move around in a UI.
Some browsers require larger segment sizes to prevent choppy playback, this can be done with this setting to create 10 second segment files which increases the time before you can get playback working.
The webview version allows you to zoom in on the video when using the iOS app, the Video element version does not zoom, but it will pass through myopenHAB.
In order to display camera hls streams side by side you can also create a webView item and link it to a HTML file in the conf/html directory as follows:
The webView URL is that of your openHAB installation.
The first method once setup allows you to ask "OK Google show X camera", or "OK Google show X camera on Y display".
By optionally naming the display that you wish to use, it can be cast directly to your Chromecast (connected to your TV) by speaking to a Google Nest Mini.
This must use the HLS format and use the metadata tag shown below with the openHAB Cloud Connector setup.
The second method is by using the Chromecast Binding and by sending the URL you wish to cast to the `playuri` channel.
You can cast the ipcamera.jpg (static picture), ipcamera.gif (looping moving picture), and ipcamera.m3u8 (aka HLS) for a non stop stream that uses low CPU and can also contain audio.
- Use the Action called `recordMP4(String filename, int secondsToRecord)` or `recordGIF(String filename, int secondsToRecord)` with the first argument being the filename you wish to use, and the second the time in seconds you wish to record for.
- Once the file is created, the channel `recordingMp4` or `recordingGif` will change itself back to `0`, which can be used to trigger a rule to send/use the file which will appear in the `ffmpegOutput` folder.
- The channel `mp4History` or `gifHistory` keeps a string of the last 50 filenames (comma separated values CSV) until you reset the history. If you use `ipcamera` as the filename, this stops the history from growing.
- The channel `mp4HistoryLength` and `gifHistoryLength` keeps track of how many recordings were made since it was last reset.
There is also a config called `gifPreroll` to be aware of.
When `gifPreroll` is 0 (the default) the binding will use the `ffmpegInput` stream to record from.
By changing the `gifPreroll` to a value above 0, the binding will change to using snapshots as the source, preventing the need to have or open a RTSP stream.
The time between the snapshots then becomes the `pollTime` of the camera (1 second by default) and can be raised if you desire.
The snapshots are saved to disk and can be used as a feature that is described in the snapshot section.
You can request the GIF and MP4 by using this URL format, or by the direct path to where the file is stored:
sendPushoverMessage(pushoverBuilder("Sending GIF from backyard").withApiKey("dsfhghj6546fghfg").withUser("qwerty54657").withDevice("Phone1").withAttachment("/tmpfs/DoorCam/ipcamera.gif"))
end
```
## HABpanel
This section is about how to get things working in HABpanel.
The widgets in the link above are the easiest way to get an advanced stream working in openHAB and you are welcome to open them up, look at how they work and change them to something even better that suits your needs.
Use the following example to base your sitemap on to save some time.
If you use the `Create Equipment from Thing` feature to auto create your items, the following will need minimal editing to change the camera name from `BabyCam` to what you choose to name the camera.