From f4f24b82389fd6a5560a79c3ae928ff40816cb36 Mon Sep 17 00:00:00 2001 From: shbatm Date: Wed, 5 Oct 2022 17:22:19 -0500 Subject: [PATCH] Add option to mute VLC streams (#100) --- CHANGELOG.md | 2 + MMM-RTSPStream.js | 1 + README.md | 21 +- node_helper.js | 3 + public/config.html | 765 ++++++++++++++++++++++++++------------------- 5 files changed, 459 insertions(+), 333 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index fbbcfe2..87ce871 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,5 @@ +## :warning: Refer to GitHub Releases page for Change Logs post [2.0.2-dev] + ## [2.0.2-dev] - Attempted fix for OMXPlayer with OpenGL (Fake KMS) enabled Changed: diff --git a/MMM-RTSPStream.js b/MMM-RTSPStream.js index a6db2da..bf02e94 100644 --- a/MMM-RTSPStream.js +++ b/MMM-RTSPStream.js @@ -37,6 +37,7 @@ Module.register("MMM-RTSPStream", { width: 320, height: 240, omxRestart: 24, // Hours + muted: false }, // MMM-KeyBindings Settings diff --git a/README.md b/README.md index ac181af..6815d1d 100644 --- a/README.md +++ b/README.md @@ -5,9 +5,10 @@ This is a module for the [MagicMirror²](https://github.com/MichMich/MagicMirror This module will show a live RTSP video stream and/or periodic snapshots on the Magic Mirror from any IP Security Camera which supports the [RTSP protocol](https://github.com/shbatm/MMM-RTSPStream/wiki/Stream-URLs-for-Various-Cameras) and/or can serve a snapshot periodically. > :warning: This module is no longer being actively developed. I will accept PRs and leave the repo active, but will not be directly supporting any issues. If anyone is interested in assuming ownership of the module, please contact @shbatm. :warning: -> +> > Why? > - I am no longer using this module on my own mirror. After several years, I found that I use the snapshots much more frequently than I streamed the actual cameras, which can be performed by much simpler modules and methods. To enable streaming, WebRTC (like [MMM-HomeAssistant-WebRTC](https://github.com/Anonym-tsk/MMM-HomeAssistant-WebRTC)) is a newer and better standard with much lower server overhead and latency for delivering RTSP Streams to the frontend than any of the options used here, in the future, this will be the method I focus on and I will not try to shoehorn another technology into this module. +> - Update 5-Oct-2022: See alternative module [MMM-RTSPtoWeb](https://github.com/shbatm/MMM-RTSPtoWeb) for a drastically simplified module relying on WebRTC and a backend server. ### Features: @@ -26,8 +27,8 @@ This module will show a live RTSP video stream and/or periodic snapshots on the ### Dependencies: * The following packages are required for the module to function fully and the installer will attempt to install them with `apt`: - * `ffmpeg`, `omxplayer`, `vlc`, `devilspie2`, `wmctrl` -* For hardware-accelerated streaming, `vlc` or `omxplayer` is required. + * `ffmpeg`, `omxplayer`, `vlc`, `devilspie2`, `wmctrl` +* For hardware-accelerated streaming, `vlc` or `omxplayer` is required. * For manipulating VLC's windows, `devilspie2` and `wmctrl` are used. * For software-decoded streaming and/or remote browser viewing: - Requires `jsmpeg` for front-end display of stream. @@ -95,7 +96,6 @@ It is highly recommended you use the tool included. Several sample configuration | `moduleHeight` | Similar (but less critical) to `moduleWidth`. Adjust to the number of streams high to ensure other modules clear.
*Default:* `240px` | `moduleOffset` | *Only applies when using OMXPlayer.* On some displays, the video does not properly line up with the box on the screen because of differences between JavaScript's reporting and the native display. Entering a pixel value will shift the video over by that amount.
*Default:* `0` *Values:* Any number (no units) by itself will adjust both top/left the same amount, or you can specify left & top adjustments separately (e.g. `moduleOffset: { left: 10, top: -10 }` | `shutdownDelay` | The time delay (in sec) between when the last client disconnects and the `ffmpeg` or `vlc` stream actually stops. Once created, the websocket continues to run in the background; however, the `ffmpeg` process will only process the camera's stream while there are active connections on the socket (e.g. someone is watching the video on the frontend). When rotating through multiple streams this prevents closing the connection to a stream only to re-open a few seconds later when it comes back through the loop (which reduces the time delay when restarting a stream). To conserve resources on a slow device, you can set this to 0
*Default:* 11 (sec) -| `omxRestart` | Automatically restart the OMX Stream every X hours.
*Default:* `24` (hours). | `debug` | Set to `true` to show additional logging information. | `streamX` | The individual stream configuration options. See table below for more details. @@ -133,9 +133,10 @@ config: { | `absPosition` | *Only required for OMXPlayer* Provide an absolute potiion to show the stream. This overrides the automatic window and moduleOffset settings.
*Format:* `{ top: XX, right: XX, bottom: XX, left: XX }` where `XX` is the pixel position on the screen. | `ffmpegPort` | *Only required for `ffmpeg`* Any available port to use for the ffmpeg websocket.
***Notes:*** **THIS IS NOT THE PORT FOR YOUR CAMERA** Camera stream's port must be included in the URL above. This port must be unqiue for each stream added and cannot be used by another service on the server. This is a separate WebSocket from the the Socket.IO connection between the module's script and it's `node_helper.js`.
*Default:* `9999` | `hwAccel` | *Only required for `ffmpeg`* Attempt to use Hardware Accelerated Decoding with `ffmpeg`.
*Default:* `false` -| `muted` | Disable sound (*OMXPlayer only*)
*Default:* `false` +| `muted` | Disable sound (*OMXPlayer and VLC only*)
*Default:* `false` | `timeout` | Timeout for stalled file/network operations (*OMXPlayer only*)
*Default:* `10` (seconds) | `rotateDegree` | Set orientation of video (*OMXPlayer only*)
Available values: `0`, `90`, `180` or `270`
*Default:* `0` +| `omxRestart` | Automatically restart the OMX Stream every X hours.
*Default:* `24` (hours). #### Testing a camera feed @@ -157,7 +158,7 @@ this.sendNotification("RTSP-PLAY", "streamX"); // Play a particular stream (when this.sendNotification("RTSP-PLAY-FULLSCREEN", "streamX"); // Play a particular stream fullscreen (when using OMXPLAYER) this.sendNotification("RTSP-PLAY-WINDOW", { name:"streamX", box: { top: XX, right: XX, bottom: XX, left: XX } }); // Play a particular stream in a custom window (when using OMXPLAYER) this.sendNotification("RTSP-STOP", "all"); // Stop the streams -this.sendNotification("RTSP-STOP", "streamX"); // Stop a particular stream +this.sendNotification("RTSP-STOP", "streamX"); // Stop a particular stream ``` ### KeyBindings Configuration (Requires [MMM-KeyBindings](https://github.com/shbatm/MMM-KeyBindings)) @@ -170,12 +171,12 @@ this.sendNotification("RTSP-STOP", "streamX"); // Stop a particular stream | `map` | The map between this module's key functions and the Keyboard / MMM-KeyBinding's key name that is sent (i.e. when the "MediaPlayPause" key is pressed, it will send a `Play` action to this module).
`Previous`/`Next` actions will cycle through the streams when `rotateStreams` is enabled, and will change which stream is selected when multiple streams are shown (red border will appear around selected stream). ```js -keyBindings: { +keyBindings: { enabled: true, mode: "DEFAULT", map: { - Play: "MediaPlayPause", - Previous: "MediaPreviousTrack", + Play: "MediaPlayPause", + Previous: "MediaPreviousTrack", Next: "MediaNextTrack", } } @@ -200,4 +201,4 @@ ffmpeg -i {RTSP_SOURCE} -f image2 -vf fps=fps=1/{x} -update 1 thumb.png // Grab the first frame from a stream and save as thumb.jpg ffmpeg -i {RTSP_SOURCE} -ss 00:00:01.500 -f image2 -vframes 1 thumb.png ``` -([source](https://superuser.com/questions/663928/ffmpeg-to-capture-stills-from-h-264-stream)) +([source](https://superuser.com/questions/663928/ffmpeg-to-capture-stills-from-h-264-stream)) diff --git a/node_helper.js b/node_helper.js index 6ce9eda..b46bd6b 100644 --- a/node_helper.js +++ b/node_helper.js @@ -214,6 +214,9 @@ module.exports = NodeHelper.create({ s.box.right - s.box.left }, ${s.box.bottom - s.box.top}`; } + if (this.config[s.name].muted) { + args.unshift("--no-audio"); + } console.log( `Starting stream ${s.name} using VLC with args ${args.join( " " diff --git a/public/config.html b/public/config.html index 59529a0..ec0fd28 100644 --- a/public/config.html +++ b/public/config.html @@ -7,9 +7,9 @@ @@ -40,62 +40,65 @@
- + Leave blank for no header.
-
- -
-
- -
-

Yes will start the streams automatically when the mirror starts, no will show snapshots (if available) or a blank window until the stream is started by a notification from another app or by clicking the play button.

+ + +

Yes will start the streams automatically when the mirror starts, no will show + snapshots (if available) or a blank window until the stream is started by a notification from + another app or by clicking the play button.

- +
- +
- - Only applies when the first option above is selected. + + Only applies when the first option above is selected.
- +
-
- -
-
- -
-

If your camera supports timed snapshot images via URL or saving to a file location, the module can display these when the stream is paused.

+ + +

If your camera supports timed snapshot images via URL or saving to a file + location, the module can display these when the stream is paused.

@@ -120,54 +123,67 @@
-
- -
-
- -
-

When using OMXPlayer for local player and None for remote player, no video will be visible if you open the Mirror on a remote web browser or view through VNC. Selecting yes for this option will show snapshots to the remote viewers (saves resources over using FFMPEG for Remote Player)

+ + +

When using OMXPlayer for local player and None for remote player, no video + will be visible if you open the Mirror on a remote web browser or view through VNC. + Selecting yes for this option will show snapshots to the remote viewers (saves resources over + using FFMPEG for Remote Player)

- + px
-

When rotateStreams is false and multiple streams are used, adjust this value to adjust the number of streams shown side by side. E.G. to show 2 streams side by side, this value should be = 2*(Stream Width + 2*1px (border) + 2*15px (margin))

+

When rotateStreams is false and multiple streams are used, adjust this value + to adjust the number of streams shown side by side. E.G. to show 2 streams side by side, this + value should be = 2*(Stream Width + 2*1px (border) + 2*15px (margin))

- + px
-

Similar (but less critical) to moduleWidth. Adjust to the number of streams high to ensure other modules clear.

+

Similar (but less critical) to moduleWidth. Adjust to the number of streams + high to ensure other modules clear.

- +
-

On some displays, the video does not properly line up with the box on the screen. Entering a pixel value will shift the video over by that amount. Default: 0 Values: Any number (no units) by itself will adjust both top/left the same amount, or you can specify left & top adjustments separately (e.g. { left: 10, top: -10 })

+

On some displays, the video does not properly line up with the box on the + screen. Entering a pixel value will shift the video over by that amount. Default: 0 Values: Any + number (no units) by itself will adjust both top/left the same amount, or you can specify left + & top adjustments separately (e.g. { left: 10, top: -10 })

- + ms
-

The time delay (in sec) between when the stream is hidden/closed and when the stream actually stops. When rotating through multiple streams this prevents closing the connection to a stream only to re-open a few seconds later when it comes back through the loop (which reduces the time delay when restarting a stream). To conserve resources on a slow device, you can set this to 0

+

The time delay (in sec) between when the stream is hidden/closed and when the + stream actually stops. When rotating through multiple streams this prevents closing the + connection to a stream only to re-open a few seconds later when it comes back through the loop + (which reduces the time delay when restarting a stream). To conserve resources on a slow device, + you can set this to 0

@@ -201,8 +217,13 @@
- - The url of the RTSP stream. See this list for paths for some common security cameras. Also see below for how to test for a valid url Username and password should be passed in the url if required: rtsp://<username>:<password>@<hostname>:<port>/<path> + + The url of the RTSP stream. See this + list for paths for some common security cameras. Also see below for how to test for a + valid url Username and password should be passed in the url if required: + rtsp://<username>:<password>@<hostname>:<port>/<path>
@@ -226,7 +247,8 @@
- + The url or filepath of the snapshot images.
@@ -234,7 +256,8 @@