* Fix urls are null until binding restarts.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* Change to using port config.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* automate the ffmpeg output folder to follow the UID.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* spotless fixes.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* Update readme.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* change to using the userdata folder.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* change to better field description.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* Add advanced.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* Add link to docs.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* improve readme.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* improve example path in readme.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
* Update bundles/org.openhab.binding.ipcamera/README.md
Cut and paste bandit strikes again. thanks.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
* Change to using ipcamera as folder loc.
Signed-off-by: Matthew Skinner <matt@pcmus.com>
Co-authored-by: Fabian Wolter <github@fabian-wolter.de>
port=80,
nvrChannel=4,
serverPort=54324,
- ffmpegOutput="/etc/openhab2/html/cameras/camera-west/",
+ ffmpegOutput="/var/lib/openhab/ipcamera/West/",
ffmpegInput="rtsp://192.168.0.XX:554/ISAPI/Streaming/channels/401"
]
```
| `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 a 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 where FFmpeg has the ability to write files to ending with a slash. For windows use this format: `c:\openhabconf\html\ipcamera\`. If you would like to expose the GIF files to your static server, you can set it to `/etc/openhab2/html/cameras/camera-name/` |
+| `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. |
+ Ensure FFmpeg is installed.
+ For `generic` cameras, you will need to use the config `ffmpegInput` to provide a HTTP or RTSP URL.
-+ Supply a folder that the openhab user has write permissions for to the config `ffmpegOutput`.
-+ Set a valid `serverPort` as the default value of -1 will turn this feature off.
++ Set a valid `serverPort` as the value of -1 will turn this feature off.
+ Consider using a SSD/HDD, zram location, or a tmpfs (ram drive) can be used if you only have micro SD/flash based storage.
### Ram Drive Setup
return ffmpegOutput;
}
+ public void setFfmpegOutput(String path) {
+ ffmpegOutput = path;
+ }
+
public boolean getPtzContinuous() {
return ptzContinuous;
}
import org.openhab.binding.ipcamera.internal.MyNettyAuthHandler;
import org.openhab.binding.ipcamera.internal.StreamServerHandler;
import org.openhab.binding.ipcamera.internal.onvif.OnvifConnection;
+import org.openhab.core.OpenHAB;
import org.openhab.core.library.types.DecimalType;
import org.openhab.core.library.types.IncreaseDecreaseType;
import org.openhab.core.library.types.OnOffType;
String temp = longUrl;
URL url;
- if (longUrl.isEmpty() || longUrl.equals("ffmpeg")) {
+ if (longUrl.isEmpty() || "ffmpeg".equals(longUrl)) {
return longUrl;
}
if (start) {
if (mjpegChannelGroup.isEmpty()) {// first stream being requested.
mjpegChannelGroup.add(ctx.channel());
- if (mjpegUri.isEmpty() || mjpegUri.equals("ffmpeg")) {
+ if (mjpegUri.isEmpty() || "ffmpeg".equals(mjpegUri)) {
sendMjpegFirstPacket(ctx);
setupFfmpegFormat(FFmpegFormat.MJPEG);
} else {
mjpegChannelGroup.remove(ctx.channel());
if (mjpegChannelGroup.isEmpty()) {
logger.debug("All ipcamera.mjpeg streams have stopped.");
- if (mjpegUri.equals("ffmpeg") || mjpegUri.isEmpty()) {
+ if ("ffmpeg".equals(mjpegUri) || mjpegUri.isEmpty()) {
Ffmpeg localMjpeg = ffmpegMjpeg;
if (localMjpeg != null) {
localMjpeg.stopConverting();
localGIF.startConverting();
if (gifHistory.isEmpty()) {
gifHistory = gifFilename;
- } else if (!gifFilename.equals("ipcamera")) {
+ } else if (!"ipcamera".equals(gifFilename)) {
gifHistory = gifFilename + "," + gifHistory;
if (gifHistoryLength > 49) {
int endIndex = gifHistory.lastIndexOf(",");
localRecord.startConverting();
if (mp4History.isEmpty()) {
mp4History = mp4Filename;
- } else if (!mp4Filename.equals("ipcamera")) {
+ } else if (!"ipcamera".equals(mp4Filename)) {
mp4History = mp4Filename + "," + mp4History;
if (mp4HistoryLength > 49) {
int endIndex = mp4History.lastIndexOf(",");
onvifCamera.sendPTZRequest(OnvifConnection.RequestType.AbsoluteMove);
}
+ @Override
+ public void channelLinked(ChannelUID channelUID) {
+ if (cameraConfig.getServerPort() > 0) {
+ switch (channelUID.getId()) {
+ case CHANNEL_MJPEG_URL:
+ updateState(CHANNEL_MJPEG_URL, new StringType(
+ "http://" + hostIp + ":" + cameraConfig.getServerPort() + "/ipcamera.mjpeg"));
+ break;
+ case CHANNEL_HLS_URL:
+ updateState(CHANNEL_HLS_URL,
+ new StringType("http://" + hostIp + ":" + cameraConfig.getServerPort() + "/ipcamera.m3u8"));
+ break;
+ case CHANNEL_IMAGE_URL:
+ updateState(CHANNEL_IMAGE_URL,
+ new StringType("http://" + hostIp + ":" + cameraConfig.getServerPort() + "/ipcamera.jpg"));
+ break;
+ }
+ }
+ }
+
@Override
public void handleCommand(ChannelUID channelUID, Command command) {
if (command instanceof RefreshType) {
if (rtspUri.isEmpty()) {
logger.warn("Binding has not been supplied with a FFmpeg Input URL, so some features will not work.");
}
- if (snapshotUri.isEmpty() || snapshotUri.equals("ffmpeg")) {
+ if (snapshotUri.isEmpty() || "ffmpeg".equals(snapshotUri)) {
snapshotIsFfmpeg();
} else {
sendHttpRequest("GET", snapshotUri, null);
cameraConfig.getOnvifPort());
onvifCamera.connect(thing.getThingTypeUID().getId().equals(ONVIF_THING));
}
- if (snapshotUri.equals("ffmpeg")) {
+ if ("ffmpeg".equals(snapshotUri)) {
snapshotIsFfmpeg();
} else if (!snapshotUri.isEmpty()) {
sendHttpRequest("GET", snapshotUri, null);
snapshotUri = getCorrectUrlFormat(cameraConfig.getSnapshotUrl());
mjpegUri = getCorrectUrlFormat(cameraConfig.getMjpegUrl());
rtspUri = cameraConfig.getFfmpegInput();
+ if (cameraConfig.getFfmpegOutput().isEmpty()) {
+ cameraConfig
+ .setFfmpegOutput(OpenHAB.getUserDataFolder() + "/ipcamera/" + this.thing.getUID().getId() + "/");
+ }
if (cameraConfig.getServerPort() < 1) {
logger.warn(
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="serverPort" type="integer" required="true" min="-1" max="65535" groupName="Settings">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">
<parameter name="ffmpegOutput" type="text" required="false" groupName="FFmpeg Setup">
<label>FFmpeg Output Folder</label>
- <description>The full path where FFmpeg has the ability to write files to ending with a slash. For windows use this
- format, c:\openhabconf\html\ipcamera\
+ <description>Leave this blank and the binding will use the openHAB userdata folder. Alternatively, a unique path for
+ each camera that ends with a slash and has write permissions can be entered.
</description>
- <default>/etc/openhab/html/camera1/</default>
+ <advanced>true</advanced>
</parameter>
<parameter name="hlsOutOptions" type="text" required="false" groupName="FFmpeg Setup">