diff --git a/bin/server.dart b/bin/server.dart index 03b7913..79ac7b1 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -433,9 +433,8 @@ Handler _createStreamHandler() { '-i', iptvUrl, - // Output format: fragmented MP4 (fMP4) for streaming - '-f', 'mp4', - '-movflags', 'frag_keyframe+empty_moov+default_base_moof', + // Output format: MPEG-TS for streaming (compatible with mpegts.js) + '-f', 'mpegts', // Video: Copy is BEST for performance (0% CPU) // Browsers support H.264 well. @@ -495,7 +494,7 @@ Handler _createStreamHandler() { return Response.ok( controller.stream, headers: { - 'Content-Type': 'video/mp4', + 'Content-Type': 'video/MP2T', 'Access-Control-Allow-Origin': '*', 'Cache-Control': 'no-cache, no-store', 'Connection': 'keep-alive', diff --git a/lib/features/iptv/screens/player_screen.dart b/lib/features/iptv/screens/player_screen.dart index 1f245b7..f38cc88 100644 --- a/lib/features/iptv/screens/player_screen.dart +++ b/lib/features/iptv/screens/player_screen.dart @@ -136,9 +136,9 @@ class _PlayerScreenState extends ConsumerState { }; final modeParam = settings.modeString; // direct, transcode, or auto - // Construct the stream URL directly using fMP4 format - // We add &ext=.mp4 to force the web player to use Direct Play instead of HLS/MPEGTS - final streamEndpoint = '$baseUrl/api/stream/${widget.streamId}?url=$encodedUrl&quality=$qualityParam&buffer=$bufferParam&timeout=$timeoutParam&mode=$modeParam&ext=.mp4'; + // Construct the stream URL directly using MPEG-TS format + // We add &ext=.ts to force the web player to use mpegts.js which is perfect for low-latency live streams + final streamEndpoint = '$baseUrl/api/stream/${widget.streamId}?url=$encodedUrl&quality=$qualityParam&buffer=$bufferParam&timeout=$timeoutParam&mode=$modeParam&ext=.ts'; debugPrint('PlayerScreen: Starting Direct Stream: $streamEndpoint');