Auto detect RTSP streams when proxy profile is selected and force FFmpeg.

This commit is contained in:
SergeantPanda 2025-11-11 17:26:56 -06:00
parent 21723e29bc
commit b608af1d51
3 changed files with 12 additions and 6 deletions

View file

@ -33,6 +33,7 @@ class EventType:
# Stream types
class StreamType:
HLS = "hls"
RTSP = "rtsp"
TS = "ts"
UNKNOWN = "unknown"

View file

@ -221,10 +221,11 @@ class StreamManager:
# Check stream type before connecting
stream_type = detect_stream_type(self.url)
if self.transcode == False and stream_type == StreamType.HLS:
logger.info(f"Detected HLS stream: {self.url} for channel {self.channel_id}")
logger.info(f"HLS streams will be handled with FFmpeg for now - future version will support HLS natively for channel {self.channel_id}")
# Enable transcoding for HLS streams
if self.transcode == False and stream_type in (StreamType.HLS, StreamType.RTSP):
stream_type_name = "HLS" if stream_type == StreamType.HLS else "RTSP/RTP"
logger.info(f"Detected {stream_type_name} stream: {self.url} for channel {self.channel_id}")
logger.info(f"{stream_type_name} streams require FFmpeg for channel {self.channel_id}")
# Enable transcoding for HLS and RTSP/RTP streams
self.transcode = True
# We'll override the stream profile selection with ffmpeg in the transcoding section
self.force_ffmpeg = True

View file

@ -7,19 +7,23 @@ logger = logging.getLogger("ts_proxy")
def detect_stream_type(url):
"""
Detect if stream URL is HLS or TS format.
Detect if stream URL is HLS, RTSP/RTP, or TS format.
Args:
url (str): The stream URL to analyze
Returns:
str: 'hls' or 'ts' depending on detected format
str: 'hls', 'rtsp', or 'ts' depending on detected format
"""
if not url:
return 'unknown'
url_lower = url.lower()
# Check for RTSP/RTP streams first (requires FFmpeg)
if url_lower.startswith('rtsp://') or url_lower.startswith('rtp://'):
return 'rtsp'
# Look for common HLS indicators
if (url_lower.endswith('.m3u8') or
'.m3u8?' in url_lower or