Sources :
On commence par installer go :
apt-get install go
Puis par télécharger le code source :
git clone https://github.com/deepch/RTSPtoWeb
On se rend dans le répertoire et on teste le lancement :
cd RTSPtoWeb/
GO111MODULE=on go run *.go
On configure le serveur :
sudo nano config.json
Par exemple :
{ "server": { "debug": true, "log_level": "info", "http_debug": false, "http_demo": true, "http_dir": "web", "http_login": "$TONLOGIN", "http_password": "$TONPASS", "http_port": ":8083", "https": true, "https_auto_tls": false, "https_auto_tls_name": "", "https_cert": "/etc/letsencrypt/live/$TONDNS/cert.pem", "https_key": "/etc/letsencrypt/live/$TONDNS/privkey.pem", "https_port": ":8084", "ice_servers": ["stun:stun.l.google.com:19302"], "log_level": "debug", "rtsp_port": ":5541", "token": { "backend": "http://127.0.0.1/test.php" }, "defaults": { "audio": true } }, "streams": { "Cam1": { "name": "Cam1", "channels": { "0": { "url": "rtsp://$TONLOGIN:$TONPASS@$TONIP:554/Streaming/Channels/102", "debug": false, "on_demand": true, "audio": true, "status": 0 } } }, "Cam2": { "name": "Cam2", "channels": { "0": { "name": "ch1", "url": "rtsp://$TONIP:554/11", "debug": false, "on_demand": true, "audio": true, "status": 0 } } } }, "channel_defaults": { "on_demand": true } }
On teste si tout fonctionne :
GO111MODULE=on go run *.go
Et lancer un navigateur et se rendre sur
https://$TONDNS:8084
Si tout fonctionne, on peut lancer le build de l'application :
sudo GO111MODULE=on go build -o /$TONPATH/RTSPtoWeb/RTSPtoWeb.bin
Puis créer le service RTSP :
sudo nano /etc/systemd/system/rtsp.service
[Unit] Description=Service RTSPtoWebRTC [Service] Type=simple Restart=always ExecStart= /$TONPATH/RTSPtoWeb/RTSPtoWeb.bin WorkingDirectory=/$TONPATH/RTSPtoWeb [Install] WantedBy=multi-user.target
On recharge les services, on lance le service RTSP et on vérifie son status :
sudo systemctl daemon-reload sudo systemctl start rtsp.service sudo systemctl status rtsp.service
Une fois que c'est testé via le navigateur, on l'ajoute au lancement lors du boot :
sudo systemctl enable rtsp.service
Exemple :
https://$TONDNS:8084
Source :
Pour l'ajouter dans une page Web, il faut utiliser videojs ( https://github.com/videojs/http-streaming?tab=readme-ov-file#initialization ). Fichiers : videojs_js_et_css.7z
Exemple dans une page PHP :
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Titre</title>
<link href="../css.css" rel="stylesheet">
<link href="css/video-js.css" rel="stylesheet" />
<!-- "core" version of Video.js -->
<script src="js/video.min.js"></script>
<script src="js/videojs-http-streaming.min.js"></script>
</head>
<body>
<?php
$TONDNS = "example.org";
$cameras = [
'Cam1',
'Cam2',
'Cam3'
];
foreach ($cameras as $valeur) {
?><video-js id=<?php echo ("'".$valeur."'");?> width='540' height='360' class="vjs-default-skin" controls autoplay muted style="margin-bottom:10px;">
<source src=<?php echo ("'https://".$TONDNS.":8084/stream/".$valeur."/channel/0/hls/live/index.m3u8'");?> type="application/x-mpegURL">
</video-js>
<script>
var player = videojs(<?php echo ("'".$valeur."'");?>);
player.play();
</script>
<?php
}
?>
</body>
Editer la config de RTSPtoWeb :
nano /$TONPATH/RTSPtoWeb/config.json
Ajouter dans les streams :
,"NomDeLaCam": { "name": "NomDeLaCam", "channels": { "0": { "name": "ch1", "url": "rtsp://IPDELACAM:554/11", "debug": false, "on_demand": true, "audio": true, "status": 0 } } }
Redémarrer le service rtsp :
sudo systemctl restart rtsp.service
Vérifier son statut :
sudo systemctl status rtsp.service
Si tout est OK, la nouvelle cam est disponible par le gestionnaire de RTSPtoWeb.
En cas de souci avec les codecs H265 https://github.com/deepch/RTSPtoWeb/issues/68
I do have a budget camera. H.265 doesn't work either. Nevertheless, mine has a h.265X option. Something related to an "AI". Anywy, i gave it a shot and it´s working fine.
Vérifier si l'option H265X existe, et si oui l'activer (ça a marché dans mon cas).