|
| 1 | +# Terminal ASCII Renderer |
| 2 | + |
| 3 | +Render images, GIFs, and videos directly in the terminal using high-detail ASCII, Unicode braille, and full 24-bit RGB color. Supports smart edge-based rendering and auto-scaling to your terminal size. |
| 4 | + |
| 5 | +--- |
| 6 | + |
| 7 | +## Features |
| 8 | + |
| 9 | +- Render **images, GIFs, and videos** in the terminal |
| 10 | +- Real-time video playback with frame timing from metadata |
| 11 | +- Smart rendering pipeline: |
| 12 | + - Sobel edge detection for detailed regions |
| 13 | + - Braille characters for high-frequency detail |
| 14 | + - Half-block Unicode for vertical contrast |
| 15 | + - ASCII fallback for smooth regions |
| 16 | +- Full 24-bit ANSI color support |
| 17 | +- Auto-resize to terminal resolution (Windows only) |
| 18 | +- Multi-file drag-and-drop support, opening each file in a separate terminal |
| 19 | +- Optional frame export as plain ASCII text |
| 20 | + |
| 21 | +--- |
| 22 | + |
| 23 | +## Supported Formats |
| 24 | + |
| 25 | +**Images:** `png`, `jpg`, `jpeg`, `bmp` |
| 26 | +**Animated:** `gif` |
| 27 | +**Videos:** `mp4`, `avi`, `mkv`, `mov` (and most OpenCV-supported formats, though this has some limitations) |
| 28 | + |
| 29 | +--- |
| 30 | + |
| 31 | +## Requirements |
| 32 | + |
| 33 | +- Python 3.8 or newer |
| 34 | + |
| 35 | +Install dependencies: |
| 36 | + |
| 37 | +```bash |
| 38 | +pip install opencv-python numpy pillow |
| 39 | +``` |
| 40 | + |
| 41 | +--- |
| 42 | + |
| 43 | +## How It Works |
| 44 | + |
| 45 | +Each frame is processed as follows: |
| 46 | + |
| 47 | +1. Resize to terminal resolution (or user-specified width/height) |
| 48 | +2. Convert to grayscale |
| 49 | +3. Apply Sobel edge detection |
| 50 | +4. Render each pixel block based on detail: |
| 51 | + - High edge → braille |
| 52 | + - High contrast → half-block Unicode |
| 53 | + - Low detail → ASCII mapping |
| 54 | +5. Apply foreground and background RGB color using ANSI codes |
| 55 | + |
| 56 | +When saving frames, ANSI formatting is stripped to provide raw ASCII output. |
| 57 | + |
| 58 | +--- |
| 59 | + |
| 60 | +## Usage |
| 61 | + |
| 62 | +### Drag and Drop (Windows) |
| 63 | + |
| 64 | +1. Place `script.py` somewhere accessible |
| 65 | +2. Drag supported file(s) onto the script |
| 66 | +3. Each file opens in a separate terminal and renders automatically |
| 67 | + |
| 68 | +--- |
| 69 | + |
| 70 | +### Command Line |
| 71 | + |
| 72 | +```bash |
| 73 | +python script.py [--save-file] [--width <WIDTH>] [--height <HEIGHT>] <file> [<file2> ...] |
| 74 | +``` |
| 75 | + |
| 76 | +Examples: |
| 77 | + |
| 78 | +```bash |
| 79 | +python script.py video.mp4 |
| 80 | +python script.py image.png --width 120 --height 40 --save-file |
| 81 | +python script.py video.mp4 gif.gif image.jpg |
| 82 | +``` |
| 83 | + |
| 84 | +- `--save-file` saves each frame as a `.txt` file in a folder named after the media file |
| 85 | +- `--width` and `--height` specify terminal dimensions (Windows only) |
| 86 | + |
| 87 | +--- |
| 88 | + |
| 89 | +## Notes on Terminal Compatibility |
| 90 | + |
| 91 | +- Works best in: |
| 92 | + - Windows Terminal |
| 93 | + - CMD with ANSI enabled |
| 94 | + - Linux terminals with truecolor support |
| 95 | +- Recommended minimum terminal size: 120x40 |
| 96 | +- Larger terminal → higher resolution output |
| 97 | + |
| 98 | +--- |
| 99 | + |
| 100 | +## Performance Considerations |
| 101 | + |
| 102 | +- Playback depends on CPU and terminal rendering speed |
| 103 | +- High-resolution videos are downscaled to fit terminal |
| 104 | +- GIFs respect embedded frame durations |
| 105 | +- Real-time rendering may stutter on slower terminals |
| 106 | + |
| 107 | +--- |
| 108 | + |
| 109 | +## Known Limitations |
| 110 | + |
| 111 | +- Terminal rendering can bottleneck FPS |
| 112 | +- Colors may vary across terminals |
| 113 | +- No audio support for videos |
| 114 | +- Braille rendering requires a Unicode-compatible font |
| 115 | +- Video rendering may stutter or flicker due to clearing and frame timing |
0 commit comments