Add audio support to MultiResolutionHLSOutput
Some checks are pending
GPU Worker CI/CD / test (push) Waiting to run
GPU Worker CI/CD / deploy (push) Blocked by required conditions

This commit is contained in:
giles
2026-02-04 20:50:14 +00:00
parent 3dda5f5f50
commit 5835344e30
2 changed files with 16 additions and 1 deletions

View File

@@ -58,6 +58,7 @@ class MultiResolutionHLSOutput:
segment_duration: float = 4.0, segment_duration: float = 4.0,
ipfs_gateway: str = "https://ipfs.io/ipfs", ipfs_gateway: str = "https://ipfs.io/ipfs",
on_playlist_update: callable = None, on_playlist_update: callable = None,
audio_source: str = None,
): ):
self.output_dir = Path(output_dir) self.output_dir = Path(output_dir)
self.output_dir.mkdir(parents=True, exist_ok=True) self.output_dir.mkdir(parents=True, exist_ok=True)
@@ -66,6 +67,7 @@ class MultiResolutionHLSOutput:
self.segment_duration = segment_duration self.segment_duration = segment_duration
self.ipfs_gateway = ipfs_gateway.rstrip("/") self.ipfs_gateway = ipfs_gateway.rstrip("/")
self._on_playlist_update = on_playlist_update self._on_playlist_update = on_playlist_update
self.audio_source = audio_source
self._is_open = True self._is_open = True
self._frame_count = 0 self._frame_count = 0
@@ -187,6 +189,10 @@ class MultiResolutionHLSOutput:
"-i", "-", "-i", "-",
] ]
# Add audio input if provided
if self.audio_source:
cmd.extend(["-i", str(self.audio_source)])
# Scale if not original resolution # Scale if not original resolution
if quality.width != self.source_width or quality.height != self.source_height: if quality.width != self.source_width or quality.height != self.source_height:
cmd.extend([ cmd.extend([
@@ -206,6 +212,14 @@ class MultiResolutionHLSOutput:
"-sc_threshold", "0", # Disable scene change detection for consistent segments "-sc_threshold", "0", # Disable scene change detection for consistent segments
]) ])
# Add audio encoding if audio source provided
if self.audio_source:
cmd.extend([
"-c:a", "aac",
"-b:a", "128k",
"-shortest", # Stop when shortest stream ends
])
# HLS output # HLS output
cmd.extend([ cmd.extend([
"-f", "hls", "-f", "hls",

View File

@@ -966,7 +966,8 @@ class StreamInterpreter:
source_size=(w, h), source_size=(w, h),
fps=fps, fps=fps,
ipfs_gateway=ipfs_gateway, ipfs_gateway=ipfs_gateway,
on_playlist_update=self.on_playlist_update on_playlist_update=self.on_playlist_update,
audio_source=audio,
) )
# Fallback to GPU single-resolution if multi-res not available # Fallback to GPU single-resolution if multi-res not available
elif GPUHLSOutput is not None and check_gpu_encode_available(): elif GPUHLSOutput is not None and check_gpu_encode_available():