# bitbranchi/simple-ascii-player architecture

> Architecture diagram of the GitHub repository bitbranchi/simple-ascii-player, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/bitbranchi/simple-ascii-player
- Repository: https://github.com/bitbranchi/simple-ascii-player

## Overview

This is a small command-line ASCII video player. The user supplies a video path and target width; the script reads frames, resizes and converts them to grayscale, maps pixel brightness to ASCII characters, and prints each frame in the terminal. The graph separates input and playback control from frame conversion and terminal output. All runtime behavior is in main.py; OpenCV and NumPy are dependencies. The relationships shown are visible in the excerpted script.

Main entry points: [`main.py`](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py) (Playback loop)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and control"]
  node_inputs["Video and width prompts<br/>[main.py]"]
  node_capture["Video capture<br/>[main.py]"]
  node_playback["Playback loop<br/>[main.py]"]
end

subgraph group_conversion["Frame conversion"]
  node_frame["Frame dimensions<br/>[main.py]"]
  node_resize_gray["Resize and grayscale<br/>[main.py]"]
  node_brightness["Brightness mapping<br/>[main.py]"]
  node_ascii_rows["ASCII row encoding<br/>[main.py]"]
end

subgraph group_output["Terminal output"]
  node_render["Frame rendering<br/>[main.py]"]
  node_keyboard["Quit-key polling<br/>[main.py]"]
end

node_user(("User"))
node_terminal["Terminal"]
node_opencv["OpenCV"]
node_numpy["NumPy"]

node_user -->|"provides inputs"| node_inputs
node_inputs -->|"opens video"| node_capture
node_capture -->|"reads frames"| node_playback
node_playback -->|"gets dimensions"| node_frame
node_frame -->|"resizes and converts"| node_resize_gray
node_resize_gray -->|"maps intensities"| node_brightness
node_brightness -->|"encodes pixels"| node_ascii_rows
node_ascii_rows -->|"joins rows"| node_render
node_render -->|"prints frame"| node_terminal
node_playback -->|"polls key"| node_keyboard
node_keyboard -->|"stops on Q"| node_playback
node_playback -->|"releases capture"| node_capture
node_capture -->|"uses video API"| node_opencv
node_resize_gray -->|"uses image operations"| node_opencv
node_keyboard -->|"checks key"| node_opencv
node_brightness -->|"uses arrays"| node_numpy

click node_inputs "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_capture "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_playback "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_frame "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_resize_gray "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_brightness "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_ascii_rows "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_render "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"
click node_keyboard "https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_inputs,node_capture,node_playback,node_user toneBlue
class node_frame,node_resize_gray,node_brightness,node_ascii_rows toneAmber
class node_render,node_keyboard toneMint
class node_terminal,node_opencv,node_numpy toneIndigo
```

## Components

### Input and control

- [Video and width prompts](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`
- [Video capture](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`
- [Playback loop](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`

### Frame conversion

- [Frame dimensions](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`
- [Resize and grayscale](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`
- [Brightness mapping](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`
- [ASCII row encoding](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`

### Terminal output

- [Frame rendering](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`
- [Quit-key polling](https://github.com/bitbranchi/simple-ascii-player/blob/main/main.py): `main.py`

### Other components

- **User**
- **Terminal**
- **OpenCV**
- **NumPy**

## Connections

- User → Video and width prompts: provides inputs (evidence: `main.py`)
- Video and width prompts → Video capture: opens video (evidence: `main.py`)
- Video capture → Playback loop: reads frames (evidence: `main.py`)
- Playback loop → Frame dimensions: gets dimensions (evidence: `main.py`)
- Frame dimensions → Resize and grayscale: resizes and converts (evidence: `main.py`)
- Resize and grayscale → Brightness mapping: maps intensities (evidence: `main.py`)
- Brightness mapping → ASCII row encoding: encodes pixels (evidence: `main.py`)
- ASCII row encoding → Frame rendering: joins rows (evidence: `main.py`)
- Frame rendering → Terminal: prints frame (evidence: `main.py`)
- Playback loop → Quit-key polling: polls key (evidence: `main.py`)
- Quit-key polling → Playback loop: stops on Q (evidence: `main.py`)
- Playback loop → Video capture: releases capture (evidence: `main.py`)
- Video capture → OpenCV: uses video API (evidence: `main.py`)
- Resize and grayscale → OpenCV: uses image operations (evidence: `main.py`)
- Quit-key polling → OpenCV: checks key (evidence: `main.py`)
- Brightness mapping → NumPy: uses arrays (evidence: `main.py`)
