Skip to content

Commit 97365ae

Browse files
committed
Fix HLS crash
1 parent 40d0b7e commit 97365ae

File tree

3 files changed

+6
-14
lines changed

3 files changed

+6
-14
lines changed

StreamingCommunity/Lib/DASH/segments.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ def _display_error_summary(self) -> None:
480480
total_segments = len(self.selected_representation.get('segment_urls', []))
481481
failed_indices = [i for i in range(total_segments) if i not in self.downloaded_segments]
482482

483-
console.print(f" [cyan]Max retries: [red]{getattr(self, 'info_maxRetry', 0)} [white]| "
483+
console.log(f"[cyan]Max retries: [red]{getattr(self, 'info_maxRetry', 0)} [white]| "
484484
f"[cyan]Total retries: [red]{getattr(self, 'info_nRetry', 0)} [white]| "
485485
f"[cyan]Failed segments: [red]{getattr(self, 'info_nFailed', 0)} [white]| "
486486
f"[cyan]Failed indices: [red]{failed_indices}")

StreamingCommunity/Lib/FFmpeg/util.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def is_png_format_or_codec(file_info):
166166
format_name = file_info.get('format_name')
167167
codec_names = file_info.get('codec_names', [])
168168

169+
console.log(f"[cyan]FFMPEG detect format: [green]{format_name}[cyan], codec: [green]{codec_names}")
169170
return format_name == 'png_pipe' or 'png' in codec_names
170171

171172

StreamingCommunity/Lib/HLS/segments.py

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,8 @@ def get_type_stream(self, segments) -> str:
165165
elif self.is_stream_aac:
166166
return "aac"
167167
else:
168-
return None
168+
console.log("[yellow]Warning: Unable to determine stream type.")
169+
return "ts" # Default to ts
169170

170171
def get_info(self) -> None:
171172
"""
@@ -275,7 +276,7 @@ async def _download_single_segment(self, client: httpx.AsyncClient, ts_url: str,
275276

276277
except Exception:
277278
if attempt + 1 == max_retry:
278-
console.print(f" -- [red]Final retry failed for segment: {index}")
279+
console.print(f" -- [red]Failed request for segment: {index}")
279280
return index, False, max_retry, 0
280281

281282
sleep_time = 0.5 + attempt * 0.5 if attempt < 2 else min(3.0, 1.02 ** attempt)
@@ -437,9 +438,6 @@ async def download_segments_async(self, description: str, type: str):
437438
finally:
438439
self._cleanup_resources(temp_dir, progress_bar)
439440

440-
if not self.download_interrupted:
441-
self._verify_download_completion()
442-
443441
return self._generate_results(type)
444442

445443
else:
@@ -524,13 +522,6 @@ def _generate_results(self, stream_type: str, output_path: str = None) -> Dict:
524522
'output_path': output_path if output_path else self.final_output_path
525523
}
526524

527-
def _verify_download_completion(self) -> None:
528-
"""Validate final download integrity."""
529-
total = len(self.segments)
530-
if len(self.downloaded_segments) / total < 0.999:
531-
missing = sorted(set(range(total)) - self.downloaded_segments)
532-
raise RuntimeError(f"Download incomplete ({len(self.downloaded_segments)/total:.1%}). Missing segments: {missing}")
533-
534525
def _cleanup_resources(self, temp_dir: str, progress_bar: tqdm) -> None:
535526
"""Ensure resource cleanup and final reporting."""
536527
progress_bar.close()
@@ -550,7 +541,7 @@ def _cleanup_resources(self, temp_dir: str, progress_bar: tqdm) -> None:
550541

551542
def _display_error_summary(self) -> None:
552543
"""Generate final error report."""
553-
console.print(f" [cyan]Max retries: [red]{self.info_maxRetry} [white] | "
544+
console.log(f"[cyan]Max retries: [red]{self.info_maxRetry} [white] | "
554545
f"[cyan]Total retries: [red]{self.info_nRetry} [white] | "
555546
f"[cyan]Failed segments: [red]{self.info_nFailed}")
556547

0 commit comments

Comments
 (0)