diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java index 3b3cbacdc0bb6..d8fbaf070b0e4 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/Ffmpeg.java @@ -131,7 +131,7 @@ public void run() { BufferedReader bufferedReader = new BufferedReader(errorStreamReader); String line = null; while ((line = bufferedReader.readLine()) != null) { - logger.debug("{}", line); + logger.trace("{}", line); switch (format) { case RTSP_ALARMS: if (line.contains("lavfi.")) { @@ -172,8 +172,9 @@ public void run() { } else if (line.contains("silence_end")) { ipCameraHandler.audioDetected(); } + case MJPEG: case SNAPSHOT: - notFrozen = true;// RTSP_ALARMS and SNAPSHOT both set this to true as there is no break. + notFrozen = true;// RTSP_ALARMS, MJPEG and SNAPSHOT all set this to true, no break. break; } } diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/InstarHandler.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/InstarHandler.java index bdacdc168bfdf..e2de2ff546212 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/InstarHandler.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/InstarHandler.java @@ -137,6 +137,16 @@ public void channelRead(@Nullable ChannelHandlerContext ctx, @Nullable Object ms && content.contains("response=\"200\";")) {// new ipCameraHandler.newInstarApi = true; ipCameraHandler.logger.debug("Alarm server sucessfully setup for a 2k+ Instar camera"); + if (ipCameraHandler.cameraConfig.getFfmpegInput().isEmpty()) { + ipCameraHandler.rtspUri = "rtsp://" + ipCameraHandler.cameraConfig.getIp() + + "/livestream/12"; + } + if (ipCameraHandler.cameraConfig.getMjpegUrl().isEmpty()) { + ipCameraHandler.mjpegUri = "/livestream/12?action=play&media=mjpeg"; + } + if (ipCameraHandler.cameraConfig.getSnapshotUrl().isEmpty()) { + ipCameraHandler.snapshotUri = "/snap.cgi?chn=12"; + } } else if (requestUrl.startsWith("/param.cgi?cmd=setmdalarm&-aname=server2&-switch=on&-interval=1") && content.startsWith("[Succeed]set ok")) { ipCameraHandler.newInstarApi = false; diff --git a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java index c424388da03c3..d12b6a8cfd537 100644 --- a/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java +++ b/bundles/org.openhab.binding.ipcamera/src/main/java/org/openhab/binding/ipcamera/internal/handler/IpCameraHandler.java @@ -906,9 +906,9 @@ public void setupFfmpegFormat(FFmpegFormat format) { case MJPEG: if (ffmpegMjpeg == null) { if (inputOptions.isEmpty()) { - inputOptions = "-hide_banner -loglevel warning"; + inputOptions = "-hide_banner"; } else { - inputOptions += " -hide_banner -loglevel warning"; + inputOptions += " -hide_banner"; } ffmpegMjpeg = new Ffmpeg(this, format, cameraConfig.getFfmpegLocation(), inputOptions, rtspUri, cameraConfig.getMjpegOptions(), "http://127.0.0.1:" + SERVLET_PORT + "/ipcamera/" @@ -1575,6 +1575,12 @@ void pollCameraRunnable() { setupFfmpegFormat(FFmpegFormat.RTSP_ALARMS); } } + // check if the thread has frozen due to camera doing a soft reboot + localFfmpeg = ffmpegMjpeg; + if (localFfmpeg != null && !localFfmpeg.getIsAlive()) { + logger.debug("MJPEG was not being produced by FFmpeg when it should have been, restarting FFmpeg."); + setupFfmpegFormat(FFmpegFormat.MJPEG); + } if (openChannels.size() > 10) { logger.debug("There are {} open Channels being tracked.", openChannels.size()); cleanChannels();