This is a module for MagicMirror² that uses MPlayer to display various video files and RTSP streams.
The main branch contains the new code (version 2).
Testing on my test environment was successful, but I did not test all option variations / combinations (yet).
See the known bugs section for reported bugs.
See the opening issues section for some more information when reporting an issue.
If you are a user of version 1 of this module, please be aware that the configuration is slightly different and that more options are available. It is advisable to move a working version of this module before installing the new version.
PIR functions have not been tested by me, as I do not use it.
$ which mplayer
/usr/bin/mplayer$ sudo apt install -y mplayer-
In your terminal, change to your MagicMirror module directory
cd ~/MagicMirror/modules -
Clone this repository
git clone https://github.com/evroom/MMM-MPlayer -
Make changes to your
config.jsfile.
Edit the file ~/MagicMirror/config/config.js to add or modify the module.
{
module: 'MMM-MPlayer',
disabled: false,
position: "top_left",
header: "MPlayer",
config: {
layout: 'row',
streamInterval: 30000,
monitorAspect: 0,
noAspect: false,
noBorder: true,
rotate: -1,
windowPosition: { x: 5, y: 225 },
windowSize: { width: 640, height: 360 },
windowWidth: 640,
windowWidthNoNewAspect: 640,
windowHeightNoNewAspect: 360,
rtspStreamOverTcp: false,
rtspStreamOverHttp: false,
preferIpv4: false,
ipv4onlyProxy: false,
videoOutputDriver: 'xv,gl,gl_nosw,vdpau,',
noSound: false,
mplayerOption: '',
windows: [
{
windowSize: { width: 640, height: 360 },
windowPosition: { x: 5, y: 225 },
streams: [
'rtsp://foo',
'rtsp://bar'
]
},
{
windowSize: { width: 640, height: 360 },
windowPosition: { x: 5, y: 590 },
streams: [
'something_one.mp4',
'something_two.mp4'
]
}
]
}
},| Option | Description |
|---|---|
streamInterval |
Cycles the streams defined in windows after the provided interval (in milliseconds).Where applicable, the streams will start from the beginning again (for example for mp4 videos). Default value: 30000 |
layout |
Places windows in a row or a column. If not set to row or column, an explicit windowPosition entry is expected in the windows object.Possible values: '' | 'row' | 'column'Default value: '' |
monitorAspect |
Set the aspect ratio of your monitor or TV screen. Remark: monitorAspect takes precedence over noAspectExample values: 16:9 | '1.7777' | 4:3 | '1.3333'Default value: 0 |
noAspect |
Disable automatic movie aspect ratio compensation. Possible values: true | falseDefault value: false |
noBorder |
Disable playing movie with window border and decorations. Possible values: true | falseDefault value: false |
rotate |
Rotate window. -1: Do not rotate (default). 0: Rotate by 90 degrees clockwise and flip. 1: Rotate by 90 degrees clockwise. 2: Rotate by 90 degrees counterclockwise. 3: Rotate by 90 degrees counterclockwise and flip. Possible values: -1 | 0 | 1 | 2Default value: -1 |
windowPosition |
Position of the first window (window-0). The other windows will be either 5px below or to the right of this window, depending on layoutvalue.Can be left empty as it can be set in the windows object.Default value: { x: 5, y: 225 } |
windowSize |
Window size for the windows. Can be left empty as it can be set in the windows object.Remark: windowSize takes precedence over windowWidthNoNewAspect, windowHeightNoNewAspect and windowWidthDefault value: { width: 640, height: 360 } |
windowWidthNoNewAspect |
Scale image to width - disables aspect calculations. Remark: windowWidthNoNewAspect takes precedence over windowHeightNoNewAspectExample value: 640Default value: '' |
windowHeightNoNewAspect |
Scale image to height - disables aspect calculations. Example value: 360Default value: '' |
windowWidth |
Set width to value and calculate height to keep correct aspect ratio. Remark: windowWidth takes precedence over windowWidthNoNewAspect and windowHeightNoNewAspectExample value: 640Default value: '' |
rtspStreamOverTcp |
Used with 'rtsp://' URLs to specify that the resulting incoming RTP and RTCP packets be streamed over TCP. Remark: rtspStreamOverTcp takes precedence over rtspStreamOverHttpPossible values: true | falseDefault value: false |
rtspStreamOverHttp |
Used with 'http://' URLs to specify that the resulting incoming RTP and RTCP packets be streamed over HTTP. Possible values: true | falseDefault value: false |
preferIpv4 |
Use IPv4 on network connections. Falls back on IPv6 automatically. Possible values: true | falseDefault value: false |
ipv4onlyProxy |
Skip the proxy for IPv6 addresses. It will still be used for IPv4 connections. Possible values: true | falseDefault value: false |
videoOutputDriver |
Specify a priority list of video output drivers to be used. Possible values: see 'mplayer -vo help' for more info. Default value: 'xv,gl,gl_nosw,vdpau,' |
noSound |
Do not play/encode sound. Possible values: true | falseDefault value: false |
mplayerOption |
Use additional mplayer option. This option is to experiment with the mplayer options. Possible values: see 'man mplayer' for the possible options. Example value: '-flip'Default value: '' |
windows |
Array of window objects with individual configuration |
windowSize |
Window size. Can be left empty but is required when layout is not 'row' or 'column'.Default value: { width: 640, height: 360 } |
windowPosition |
Position of the window. Can be left empty but is required when layout is not 'row' or 'column'.Default value: { x: 5, y: 225 } |
| other options | All options, except for streamInterval, layout and monitorAspect can be used on the windows window objects. |
streams |
URL of the mp4 or rtsp stream(s). Default value:'http://stream1.example.com/video1' |
{
module: 'MMM-MPlayer',
header: "SECURIY CAM",
disabled: false,
position: "top_left",
config: {
layout: '',
streamInterval: 30 * 1000,
monitorAspect: 0,
noAspect: false,
noBorder: true,
rotate: -1,
windowPosition: '',
windowSize: '',
windowWidthNoNewAspect: false,
windowHeightNoNewAspect: false,
windowWidth: '',
rtspStreamOverTcp: false,
rtspStreamOverHttp: false,
preferIpv4: false,
ipv4onlyProxy: false,
videoOutputDriver: 'xv,gl,gl_nosw,vdpau,',
noSound: false,
mplayerOption: '',
windows: [
{
windowPosition: { x: 5, y: 225 },
windowSize: { width: 640, height: 360 },
rtspStreamOverTcp: true,
noSound: true,
streams: [
'rtsp://user:[email protected]/axis-media/media.amp?streamprofile=ACC_Low'
]
}
]
}
},These public streams can be used for testing:
- http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
- http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4
- http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/VolkswagenGTIReview.mp4
This procedure has been tested on:
Test environment:
- MagicMirror version: v2.30.0
- Raspberry Pi 3 Model B Plus Rev 1.3 (1 GB RAM)
- Raspbian GNU/Linux 12 (bookworm)
Production environment:
- MagicMirror version: v2.30.0
- Raspberry Pi 4 Model B Rev 1.5 with 8 GB RAM
- Debian GNU/Linux 12 (bookworm)
[Still under development]
This module has support for the module MMM-pages:
https://github.com/sdetweil/MMM-pages
It will start and stop the video stream based on the notifications:
- NEW_PAGE
- PAGE_CHANGED
- SHOW_HIDDEN_PAGE
- LEAVE_HIDDEN_PAGE
If payload == 0 then START_STREAM_CYCLE else STOP_STREAM_CYCLE.
Requirement for the moment, is that MMM-MPlayer needs to have page index 0, so it needs to be the first page in the config.
As it takes time before mplayer actually starts streaming, it can come to unwanted behaviour when the rotationTime is too short.
- When streaming a network camera using RTSP, it has been reported that the stream may lag or even freeze. It is not clear yet if this is a limitation of the Raspberry Pi or that the RTSP stream is causing this. One can try setting
rtspStreamOverTcporrtspStreamOverHttptotrueto see if this improves streaming.
- None
Opening an Issue is possible, but I cannot promise to be able to do something about it.
The code for the module was inherited and many stuff heavily depends on the MPlayer code (the latest MPlayer release is 1.5, created on 2022-02-27).
When opening an issue, be sure to include you config, a good description of the issue and [MMM-MPlayer] entries you might find in the log(s). Activating the logLevel DEBUG will give extra information.
It is always recommended to first try if the stream will open in, for example, VLC Player and/or to use one of the public streams for testing, to see if streaming is possible at all.
One can also copy / paste the DISPLAY=:0 mplayer ... string to the SSH terminal to see what happens and make adaptations to the mplayer command without the need of changing the MMM-MPlayer settings in the config.js file.
Raspberry Pi (Debian) based, but might apply for other platforms as well.
$ grep version ~/MagicMirror/package.json
$ cat /proc/device-tree/model; echo
$ lsb_release -a
$ uname -a
$ free -h -t$ ps -eaf | grep mplayer | grep -v grep$ pm2 flush
$ pm2 restart MagicMirror
$ sleep 20
$ grep 'MMM-MPlayer' ~/.pm2/logs/MagicMirror-*.logCode provided by user 'myfingersarecold'.
https://forum.magicmirror.builders/user/myfingersarecold
Code adapted by user 'evroom'.
https://forum.magicmirror.builders/user/evroom
Code adapted by user 'maxbethge'.
https://github.com/maxbethge
MPlayer Documentation:
http://www.mplayerhq.hu/design7/documentation.html
MPlayer man pages:
$ man mplayer
This project is licensed under the MIT License - see the LICENSE file for details.