Skip to content

Instantly share code, notes, and snippets.

@ricardodeazambuja
Created December 8, 2024 20:41
Show Gist options
  • Save ricardodeazambuja/010873f7042e5379ed70d3c8e0c12439 to your computer and use it in GitHub Desktop.
Save ricardodeazambuja/010873f7042e5379ed70d3c8e0c12439 to your computer and use it in GitHub Desktop.
CNCjs running on RPI4 as a service and with webcam enabled
{
"commands": [
{
"enabled": true,
"title": "Reboot",
"commands": "sudo reboot now"
},
{
"enabled": true,
"title": "Shutdown",
"commands": "sudo shutdown now"
}
],
}
[Unit]
Description=CNCjs with webcam
After=network.target
StartLimitIntervalSec=0
[Service]
Type=simple
Restart=always
RestartSec=1
User=pi
ExecStart=/home/pi/launch_cncjs.sh
[Install]
WantedBy=multi-user.target
# $ sudo vi /etc/systemd/system/cncjs.service
# $ sudo systemctl daemon-reload
# $ $ sudo systemctl enable cncjs.service
#! /bin/bash
cncjs &
CNCJS_PID=$!
ffmpeg -input_format mjpeg -video_size 640x480 -i /dev/video0 -c copy -f mjpeg - | streameye
kill $CNCJS_PID
# $ vi /home/pi/launch_cncjs.sh
# $ chmod +x /home/pi/launch_cncjs.sh
@ricardodeazambuja
Copy link
Author

Installing CNCjs

$ sudo apt update
$ sudo apt install npm
$ sudo reboot
$ sudo npm install -g cncjs@latest --unsafe-perm
$ sudo npm i --package-lock-only
$ sudo npm audit fix --force

Installing software to enable the use of webcam

$ sudo apt install ffmpeg
$ git clone https://github.com/ccrisan/streameye.git
$ cd streameye/
$ make
$ sudo make install

Create script (/home/pi)

$ vi launch_cncjs.sh
...

Create service definition file and enable service

$ sudo vi /etc/systemd/system/cncjs.service
...
$ sudo systemctl daemon-reload
$ sudo systemctl enable cncjs.service
$ sudo systemctl start cncjs.service

Versions that I'm currently using

$ uname -a
Linux raspberrypi 6.1.21-v8+ #1642 SMP PREEMPT Mon Apr  3 17:24:16 BST 2023 aarch64 GNU/Linux
$ lsb_release -a
Distributor ID: Debian
Description: Debian GNU/Linux 11 (bullseye)
Release: 11
Codename: bullseye
$ cncjs --version
1.10.5
$ streameye
2024-12-08 14:33:33: INFO : streamEye 0.9
$ ffmpeg
ffmpeg version 4.3.8-0+deb11u1+rpt1 Copyright (c) 2000-2024 the FFmpeg developers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment