feat: add automatic media normalization, R2 retention cleanup, and seamless playout loops

This commit is contained in:
zwitschi committed 2026-08-13 11:59:46 +02:00
1 parent e15d89edfe
commit 06ab5b4655
16 files changed
+1103 -408

No files matched your search

+4 -27
View File
@@ -19,36 +19,13 @@ fi
# Run normalization validation using the Go tool
echo "Validating playlist and enforcing normalization (ADR-001/ADR-003)..."
if ! /app/playlist-manager "$PLAYLIST_PATH"; then
if ! /app/playlist-manager -validate "$PLAYLIST_PATH"; then
echo "ERROR: Playlist validation failed. Check logs."
exit 1
fi
echo "Playlist validated successfully. Starting continuous HLS playout..."
mkdir -p /app/hls
rm -f /app/hls/playlist.m3u8 /app/hls/init.mp4 /app/hls/segment_*.ts /app/hls/segment_*.m4s
# Run FFmpeg in a loop for continuous playback
while true; do
echo "[$(date)] Starting FFmpeg playout with browser-safe HLS encoding..."
ffmpeg -re -f concat -safe 0 -i "$PLAYLIST_PATH" \
-map 0:v:0 -map 0:a:0? \
-vf "scale=1280:720:force_original_aspect_ratio=decrease,pad=1280:720:(ow-iw)/2:(oh-ih)/2,fps=30,format=yuv420p" \
-c:v libx264 -preset veryfast -pix_fmt yuv420p \
-profile:v high -level 4.0 \
-r 30 -g 60 -keyint_min 60 -sc_threshold 0 \
-c:a aac -ar 48000 -ac 2 -b:a 128k \
-f hls \
-hls_time "${HLS_SEGMENT_DURATION}" \
-hls_list_size "${HLS_WINDOW_SIZE}" \
-hls_segment_type fmp4 \
-hls_fmp4_init_filename init.mp4 \
-strftime 1 \
-hls_flags delete_segments+independent_segments \
-hls_segment_filename "/app/hls/segment_%Y%m%d_%H%M%S.m4s" \
"/app/hls/playlist.m3u8" || echo "FFmpeg exited with error (will restart in 5s per ADR-001 resilience requirements)..."
echo "Playout loop crashed or ended. Restarting in 5 seconds..."
sleep 5
done
# Single source of truth: the Go binary runs the full loop (HLS, R2 sync,
# slate fallback, health server). The shell no longer duplicates the FFmpeg loop.
exec /app/playlist-manager "$PLAYLIST_PATH"