Show streamlink/ffmpeg stderr for debugging, handle startup errors

- stderr from both processes now displayed in console
- streamlink checked for early exit before starting ffmpeg
- RuntimeError shown to user if stream unavailable

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-05 10:52:29 +01:00
parent 402d44111e
commit 811608911a
2 changed files with 57 additions and 14 deletions

30
main.py
View File

@@ -28,20 +28,26 @@ async def run(config) -> None:
frame_number = 0
async for frame_data in capture_frames(
config.channel, config.quality, config.interval
):
frame_number += 1
console.print(f"[dim]Captured frame #{frame_number}, analyzing...[/dim]")
try:
async for frame_data in capture_frames(
config.channel, config.quality, config.interval
):
frame_number += 1
console.print(f"[dim]Captured frame #{frame_number}, analyzing...[/dim]")
try:
description = await analyzer.analyze_frame(frame_data)
except Exception as e:
console.print(f"[bold red]Analysis error:[/bold red] {e}")
continue
try:
description = await analyzer.analyze_frame(frame_data)
except Exception as e:
console.print(f"[bold red]Analysis error:[/bold red] {e}")
continue
print_description(description, frame_number)
await log_description(config.log_file, description, frame_number)
print_description(description, frame_number)
await log_description(config.log_file, description, frame_number)
except RuntimeError as e:
console.print(f"[bold red]Error:[/bold red] {e}")
finally:
if frame_number == 0:
console.print("[bold yellow]No frames were captured.[/bold yellow]")
def main() -> None: