From c9a212ec4fd8a5c55d64b160df836bf6aee07991 Mon Sep 17 00:00:00 2001 From: Michael SCHAL Date: Mon, 9 Mar 2026 13:52:46 +0100 Subject: [PATCH] feat: implement live HLS streaming with FFmpeg transcoding, GPU acceleration, and HLS segment serving. --- bin/api/streaming_handler.dart | 22 +++++++++++++++------- task.md | 1 + 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/bin/api/streaming_handler.dart b/bin/api/streaming_handler.dart index 17dbfd9..327dcd7 100644 --- a/bin/api/streaming_handler.dart +++ b/bin/api/streaming_handler.dart @@ -176,12 +176,15 @@ Handler createLiveStreamHandler( '-hls_time', '2', // Small segments for low latency '-hls_list_size', '5', // 10 seconds of history '-hls_flags', 'delete_segments+independent_segments', - '-hls_segment_type', 'mpegts', - '-hls_segment_filename', '${streamDir.path}/seg_%03d.ts', - '${streamDir.path}/playlist.m3u8', + '-hls_segment_filename', 'seg_%03d.ts', + 'playlist.m3u8', ]; - final process = await Process.start(_getFFmpegPath(), ffmpegArgs); + final process = await Process.start( + _getFFmpegPath(), + ffmpegArgs, + workingDirectory: streamDir.path, + ); _liveProcesses[streamId] = process; process.stderr @@ -205,6 +208,7 @@ Handler createLiveStreamHandler( 'Content-Type': 'application/vnd.apple.mpegurl', 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-cache', + 'X-Content-Type-Options': 'nosniff', }); }); @@ -432,14 +436,18 @@ Handler createVodStreamHandler( '-hls_segment_type', 'mpegts', '-hls_segment_filename', - '${streamDir.path}/segment_%03d.ts', + 'segment_%03d.ts', '-start_number', '0', - '${streamDir.path}/playlist.m3u8', + 'playlist.m3u8', ]); final ffmpegPath = _getFFmpegPath(); - Process.start(ffmpegPath, ffmpegArgs).then((process) { + Process.start( + ffmpegPath, + ffmpegArgs, + workingDirectory: streamDir.path, + ).then((process) { _vodProcesses[streamId] = process; process.stderr.transform(utf8.decoder).listen((data) { diff --git a/task.md b/task.md index bdf8f80..cc84fa4 100644 --- a/task.md +++ b/task.md @@ -21,6 +21,7 @@ Refonte du Guide TV pour inclure les catégories et corriger l'EPG. - [x] Alignement UI Mobile (Tri, EPG, URLs) - [x] Correction Connectivité Mobile (Auto-origin + Manuel Override) - [x] Compatibilité Streaming iOS (HLS Live + Proxy Streaming) +- [x] Correction Chemins HLS Relatifs (Bug chemins absolus FFmpeg) ## Progress Log