Initial commit - stream factory

This commit is contained in:
2026-03-18 11:53:05 +01:00
commit 89cbb7e1c8
7 changed files with 100 additions and 0 deletions

14
.gitignore vendored Normal file
View File

@ -0,0 +1,14 @@
# HLS runtime
hls/*
!hls/.keep
# logs
logs/*
!logs/.keep
# temp
*.log
# system
*.pid
*.sock

30
bin/http-hls.sh Executable file
View File

@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -e
LOG="/opt/stream-factory/logs/cnews.log"
HLS_DIR="/opt/stream-factory/hls"
mkdir -p "$HLS_DIR"
echo "$(date '+%F %T') - Démarrage FFmpeg Freebox CNEWS" >> "$LOG"
exec ffmpeg \
-rtsp_transport udp \
-i "rtsp://mafreebox.freebox.fr/fbxtv_pub/stream?namespace=1&service=679&flavour=sd" \
-map 0:v:0 \
-map 0:a:0 \
-sn \
-vf scale=1024:576 \
-c:v libx264 \
-preset veryfast \
-b:v 1500k \
-g 50 \
-c:a aac \
-b:a 128k \
-f hls \
-hls_time 4 \
-hls_list_size 10 \
-hls_flags delete_segments+append_list+independent_segments \
-hls_segment_filename "$HLS_DIR/cnews_%03d.ts" \
"$HLS_DIR/cnews.m3u8"
>> "$LOG" 2>&1

0
hls/.keep Normal file
View File

0
logs/.keep Normal file
View File

13
scripts/restart_stream.sh Executable file
View File

@ -0,0 +1,13 @@
#!/bin/bash
echo "=== Restart CNEWS $(date) ===" >> /opt/stream-factory/logs/restart_stream.log
systemctl stop cnews-http.service
systemctl stop http-hls.service
rm -f /opt/stream-factory/hls/*
systemctl start http-hls.service
sleep 3
systemctl start cnews-http.service
echo "=== Restart terminé $(date) ===" >> /opt/stream-factory/logs/restart_stream.log

View File

@ -0,0 +1,13 @@
[Unit]
Description=CNEWS HLS HTTP Server
After=network.target
[Service]
User=eveny
WorkingDirectory=/opt/stream-factory/hls
ExecStart=/usr/bin/python3 -m http.server 8080
Restart=always
RestartSec=2
[Install]
WantedBy=multi-user.target

30
services/http-hls.service Normal file
View File

@ -0,0 +1,30 @@
[Unit]
Description=HLS Stream
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStart=/opt/stream-factory/bin/http-hls.sh
# 🔥 CRITIQUE
Restart=always
RestartSec=5
# 🔒 stabilité
KillSignal=SIGINT
TimeoutStopSec=10
# 👤 user
User=eveny
WorkingDirectory=/opt/stream-factory
# 📜 logs
StandardOutput=journal
StandardError=journal
# 🧠 évite blocage
StartLimitInterval=0
[Install]
WantedBy=multi-user.target