feat: Initial pipeline for Twitch highlight detection

- New 2-of-3 detection system (chat + audio + color)
- GPU support (PyTorch ROCm/CUDA ready)
- Draft mode (360p) for fast testing
- HD mode (1080p) for final render
- Auto download video + chat
- CLI pipeline script
- Documentation in Spanish
This commit is contained in:
ren
2026-02-18 20:41:58 -03:00
parent f9836a4265
commit fb8b390740
21 changed files with 1412 additions and 673 deletions

106
highlight.md Normal file
View File

@@ -0,0 +1,106 @@
# Highlight Detector Pipeline
Pipeline completo para detectar y generar highlights de streams de Twitch/Kick.
## Requisitos
```bash
# Instalar dependencias del sistema
sudo pacman -S ffmpeg streamlink dotnet-sdk --noconfirm
# Instalar dependencias de Python
pip install --break-system-packages moviepy opencv-python-headless scipy numpy python-dotenv
# Instalar TwitchDownloaderCLI (ya incluido en /usr/local/bin)
```
## Uso
### 1. Descargar Stream
```bash
# Usar streamlink (incluye video + audio)
bajar "https://www.twitch.tv/videos/2701190361"
# O manualmente con streamlink
streamlink "https://www.twitch.tv/videos/2701190361" best -o video.mp4
```
### 2. Descargar Chat
```bash
# Usar TwitchDownloaderCLI
TwitchDownloaderCLI chatdownload --id 2701190361 -o chat.json
```
### 3. Detectar Highlights
```bash
# Convertir chat a texto y detectar highlights
python3 detector.py
# Esto genera:
# - chat.txt (chat en formato texto)
# - highlights.json (timestamps de highlights)
```
### 4. Generar Video Resumen
```bash
python3 generate_video.py
# Esto genera:
# - highlights.mp4 (video con los mejores momentos)
```
## Automatizado (Un solo comando)
```bash
# Downloader + Chat + Detect + Generate
./pipeline.sh <video_id> <output_name>
```
## Parámetros Ajustables
En `detector.py`:
- `min_duration`: Duración mínima del highlight (default: 10s)
- `threshold`: Umbral de detección (default: 2.0 desviaciones estándar)
En `generate_video.py`:
- `padding`: Segundos adicionales antes/después del highlight (default: 5s)
## GPU vs CPU
**El pipeline actual es 100% CPU.**
Para mejor rendimiento:
- **MoviePy**: Usa CPU (puede usar GPU con ffmpeg)
- **Análisis de video**: CPU con OpenCV
- **Audio**: CPU con librosa
Para hacer GPU-dependiente:
- Usar `PyTorch`/`TensorFlow` para detección
- Usar GPU de la GPU para renderizado con ffmpeg
## Estructura de Archivos
```
Twitch-Highlight-Detector/
├── .env # Credenciales
├── main.py # Entry point
├── requirements.txt
├── bajar # Script para descargar streams
├── detector.py # Detección de highlights
├── generate_video.py # Generación de video
├── pipeline.sh # Pipeline automatizado
├── chat.json # Chat descargado
├── chat.txt # Chat en formato texto
├── highlights.json # Timestamps de highlights
└── highlights.mp4 # Video final
```
## Notas
- El chat de VODs antiguos puede no estar disponible (Twitch lo elimina)
- El threshold bajo detecta más highlights (puede ser ruido)
- Duraciones muy cortas pueden no ser highlights reales