Webrec: a live audio video recorder via a web page
From Wiki-Fou
Webrec is an online tool to record live audio video (webcam) stream from a webpage, the video is stored in a folder accessible from nuvol (nextcloud)
Utilisation
- Go to : https://webrec.calafou.org/
- Authorize your webcam and microphone
- Press START REC
- Press STOP REC
The videos are stored in /opt/webavrecorder/recordings this folder is accessible via nuvol as an external storage (you have to be admin in the nextcloud to add this kind of storage)
chown -R www-data: /opt/webavrecorder/
Installation
0. Récupérer les fichiers du projet
1. Installation
# 1. Installer la dépendance npm install
# 2. Lancer le serveur en ayant préalablement changé le port à 9090 node server.js
# 3. Ouvrir le navigateur http://localhost:9090 --- ## Architecture Navigateur (index.html) └── MediaRecorder API → chunks binaires (WebM/VP9) └── WebSocket → server.js (Node.js) └── fs.createWriteStream → recordings/rec_xxxx.webm
Créer un vhost apache avec un certificat https pour proxy le traffic vers le serveur nodejs
webrec.calafou-le-ssl.conf
# ──────────────────────────────────────────────────────────────
# Prérequis — activer les modules Apache nécessaires :
#
# sudo a2enmod proxy proxy_http proxy_wstunnel ssl rewrite headers
# sudo systemctl reload apache2
# ──────────────────────────────────────────────────────────────
# ── Redirection HTTP → HTTPS ───────────────────────────────────
<VirtualHost *:80>
ServerName webrec.calafou.org
RewriteEngine On
RewriteRule ^(.*)$ https://%{HTTP_HOST}$1 [R=301,L]
</VirtualHost>
# ── HTTPS + Proxy WebSocket ────────────────────────────────────
<VirtualHost *:443>
ServerName webrec.calafou.org
# ── Certificat Let's Encrypt (généré par Certbot) ──────────
SSLEngine On
SSLCertificateFile /etc/letsencrypt/live/calafou.org-0002/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/calafou.org-0002/privkey.pem
# Options SSL recommandées
SSLProtocol all -SSLv3 -TLSv1 -TLSv1.1
SSLCipherSuite ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384
SSLHonorCipherOrder off
SSLSessionTickets off
# ── En-têtes de sécurité ───────────────────────────────────
Header always set Strict-Transport-Security "max-age=63072000"
Header always set X-Frame-Options "SAMEORIGIN"
Header always set X-Content-Type-Options "nosniff"
# ── Proxy HTTP → Node.js ───────────────────────────────────
ProxyRequests Off
ProxyPreserveHost On
# Upgrade WebSocket : doit être AVANT la règle ProxyPass générale
RewriteEngine On
RewriteCond %{HTTP:Upgrade} =websocket [NC]
RewriteRule ^/?(.*) ws://127.0.0.1:9090/$1 [P,L]
# Tout le reste → HTTP classique vers Node
ProxyPass / http://127.0.0.1:9090/
ProxyPassReverse / http://127.0.0.1:9090/
# ── Logs ───────────────────────────────────────────────────
ErrorLog ${APACHE_LOG_DIR}/webcam_error.log
CustomLog ${APACHE_LOG_DIR}/webcam_access.log combined
</VirtualHost>
1. Copier les fichiers du projet
sudo mkdir -p /opt/webavrecorder sudo cp server.js package.json /opt/webavrecorder/ cd /opt/calafou-recorder && sudo npm install sudo mkdir -p /opt/webavrecorder/recordings sudo chown -R www-data:www-data /opt/webavrecorder
calafou-recorder.service
[Unit] Description=Calafou Web Recorder — serveur WebSocket Node.js After=network.target [Service] Type=simple User=www-data WorkingDirectory=/opt/webavrecorder ExecStart=/usr/bin/node server.js Restart=on-failure RestartSec=5 # Logs vers journald StandardOutput=journal StandardError=journal SyslogIdentifier=calafou-recorder # Sécurité NoNewPrivileges=true PrivateTmp=true [Install] WantedBy=multi-user.target
2. Installer et activer le service
sudo cp calafou-recorder.service /etc/systemd/system/ sudo systemctl daemon-reload sudo systemctl enable calafou-recorder sudo systemctl start calafou-recorder
3. Vérifier
sudo systemctl status calafou-recorder # Logs en temps réel : sudo journalctl -u calafou-recorder -f
