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:
218
README.md
218
README.md
@@ -1,5 +1,213 @@
|
||||
## Known issues:
|
||||
- Configure logger with config file
|
||||
- Support multiple streamer
|
||||
- Post process with ffmpeg
|
||||
- Avoid using streamer name. Need to use id instead
|
||||
# 🎬 Twitch Highlight Detector
|
||||
|
||||
Pipeline automatizado para detectar y generar highlights de streams de Twitch y Kick.
|
||||
|
||||
## ✨ Características
|
||||
|
||||
- **Descarga automática** de VODs y chat
|
||||
- **Detección 2 de 3**: Chat saturado + Audio (gritos) + Colores brillantes
|
||||
- **Modo Draft**: Procesa en 360p para prueba rápida
|
||||
- **Modo HD**: Procesa en 1080p para calidad máxima
|
||||
- **Soporte GPU**: Preparado para NVIDIA (CUDA) y AMD (ROCm)
|
||||
- **CLI simple**: Un solo comando para todo el pipeline
|
||||
|
||||
## 🚀 Uso Rápido
|
||||
|
||||
```bash
|
||||
# Modo Draft (360p) - Prueba rápida
|
||||
./pipeline.sh <video_id> <nombre> --draft
|
||||
|
||||
# Modo HD (1080p) - Alta calidad
|
||||
./pipeline.sh <video_id> <nombre> --hd
|
||||
```
|
||||
|
||||
### Ejemplo
|
||||
|
||||
```bash
|
||||
# Descargar y procesar en modo draft
|
||||
./pipeline.sh 2701190361 elxokas --draft
|
||||
|
||||
# Si te gusta, procesar en HD
|
||||
./pipeline.sh 2701190361 elxokas_hd --hd
|
||||
```
|
||||
|
||||
## 📋 Requisitos
|
||||
|
||||
### Sistema
|
||||
```bash
|
||||
# Arch Linux
|
||||
sudo pacman -S ffmpeg streamlink git
|
||||
|
||||
# Ubuntu/Debian
|
||||
sudo apt install ffmpeg streamlink git
|
||||
|
||||
# macOS
|
||||
brew install ffmpeg streamlink git
|
||||
```
|
||||
|
||||
### Python
|
||||
```bash
|
||||
pip install moviepy opencv-python scipy numpy python-dotenv torch
|
||||
```
|
||||
|
||||
### .NET (para TwitchDownloaderCLI)
|
||||
```bash
|
||||
# Descarga el binario desde releases o compila
|
||||
# https://github.com/lay295/TwitchDownloader/releases
|
||||
```
|
||||
|
||||
## 📖 Documentación
|
||||
|
||||
| Archivo | Descripción |
|
||||
|---------|-------------|
|
||||
| [README.md](README.md) | Este archivo |
|
||||
| [CONtexto.md](contexto.md) | Historia y contexto del proyecto |
|
||||
| [TODO.md](TODO.md) | Lista de tareas pendientes |
|
||||
| [HIGHLIGHT.md](HIGHLIGHT.md) | Guía de uso del pipeline |
|
||||
|
||||
## 🔧 Instalación
|
||||
|
||||
### 1. Clonar el repo
|
||||
```bash
|
||||
git clone https://tu-gitea/twitch-highlight-detector.git
|
||||
cd twitch-highlight-detector
|
||||
```
|
||||
|
||||
### 2. Configurar credenciales
|
||||
```bash
|
||||
cp .env.example .env
|
||||
# Edita .env con tus credenciales de Twitch
|
||||
```
|
||||
|
||||
### 3. Instalar dependencias
|
||||
```bash
|
||||
pip install -r requirements.txt
|
||||
```
|
||||
|
||||
### 4. Instalar TwitchDownloaderCLI
|
||||
```bash
|
||||
# Descargar desde releases
|
||||
curl -L -o TwitchDownloaderCLI https://github.com/lay295/TwitchDownloader/releases/latest/download/TwitchDownloaderCLI
|
||||
chmod +x TwitchDownloaderCLI
|
||||
sudo mv TwitchDownloaderCLI /usr/local/bin/
|
||||
```
|
||||
|
||||
## 🎯 Cómo Funciona
|
||||
|
||||
### Pipeline (2 de 3)
|
||||
|
||||
El sistema detecta highlights cuando se cumplen al menos 2 de estas 3 condiciones:
|
||||
|
||||
1. **Chat saturado**: Muchos mensajes en poco tiempo
|
||||
2. **Audio intenso**: Picos de volumen (gritos, momentos épicos)
|
||||
3. **Colores brillantes**: Efectos visuales, cambios de escena
|
||||
|
||||
### Flujo
|
||||
|
||||
```
|
||||
1. streamlink → Descarga video (VOD)
|
||||
2. TwitchDownloaderCLI → Descarga chat
|
||||
3. detector_gpu.py → Analiza chat + audio + color
|
||||
4. generate_video.py → Crea video resumen
|
||||
```
|
||||
|
||||
## 📁 Estructura
|
||||
|
||||
```
|
||||
├── .env # Credenciales (noCommit)
|
||||
├── .gitignore
|
||||
├── requirements.txt # Dependencias Python
|
||||
├── main.py # Entry point
|
||||
├── pipeline.sh # Pipeline completo
|
||||
├── detector_gpu.py # Detector (chat + audio + color)
|
||||
├── generate_video.py # Generador de video
|
||||
├── lower # Script descarga streams
|
||||
├── README.md # Este archivo
|
||||
├── CONtexto.md # Contexto del proyecto
|
||||
├── TODO.md # Tareas pendientes
|
||||
└── HIGHLIGHT.md # Guía detallada
|
||||
```
|
||||
|
||||
## ⚙️ Configuración
|
||||
|
||||
### Parámetros del Detector
|
||||
|
||||
Edita `detector_gpu.py` para ajustar:
|
||||
|
||||
```python
|
||||
--threshold # Sensibilidad (default: 1.5)
|
||||
--min-duration # Duración mínima highlight (default: 10s)
|
||||
--device # GPU: auto/cuda/cpu
|
||||
```
|
||||
|
||||
### Parámetros del Video
|
||||
|
||||
Edita `generate_video.py`:
|
||||
|
||||
```python
|
||||
--padding # Segundos extra antes/después (default: 5)
|
||||
```
|
||||
|
||||
## 🖥️ GPU
|
||||
|
||||
### NVIDIA (CUDA)
|
||||
```bash
|
||||
pip install torch torchvision --index-url https://download.pytorch.org/whl/cu121
|
||||
```
|
||||
|
||||
### AMD (ROCm)
|
||||
```bash
|
||||
pip install torch torchvision --index-url https://download.pytorch.org/whl/rocm7.1
|
||||
```
|
||||
|
||||
**Nota**: El procesamiento actual es CPU-bound. GPU acceleration es future work.
|
||||
|
||||
## 🔨 Desarrollo
|
||||
|
||||
### Tests
|
||||
```bash
|
||||
# Test detector con video existente
|
||||
python3 detector_gpu.py --video video.mp4 --chat chat.json --output highlights.json
|
||||
```
|
||||
|
||||
### Pipeline Manual
|
||||
```bash
|
||||
# 1. Descargar video
|
||||
streamlink "https://www.twitch.tv/videos/ID" best -o video.mp4
|
||||
|
||||
# 2. Descargar chat
|
||||
TwitchDownloaderCLI chatdownload --id ID -o chat.json
|
||||
|
||||
# 3. Detectar highlights
|
||||
python3 detector_gpu.py --video video.mp4 --chat chat.json --output highlights.json
|
||||
|
||||
# 4. Generar video
|
||||
python3 generate_video.py --video video.mp4 --highlights highlights.json --output final.mp4
|
||||
```
|
||||
|
||||
## 📊 Resultados
|
||||
|
||||
Con un stream de 5.3 horas (19GB):
|
||||
- Chat: ~13,000 mensajes
|
||||
- Picos detectados: ~139
|
||||
- Highlights útiles (>5s): 4-10
|
||||
- Video final: ~1-5 minutos
|
||||
|
||||
## 🤝 Contribuir
|
||||
|
||||
1. Fork el repo
|
||||
2. Crea una branch (`git checkout -b feature/`)
|
||||
3. Commit tus cambios (`git commit -m 'Add feature'`)
|
||||
4. Push a la branch (`git push origin feature/`)
|
||||
5. Abre un Pull Request
|
||||
|
||||
## 📝 Licencia
|
||||
|
||||
MIT License - Ver LICENSE para más detalles.
|
||||
|
||||
## 🙏 Créditos
|
||||
|
||||
- [TwitchDownloader](https://github.com/lay295/TwitchDownloader) - Chat downloading
|
||||
- [streamlink](https://streamlink.github.io/) - Video downloading
|
||||
- [MoviePy](https://zulko.github.io/moviepy/) - Video processing
|
||||
- [PyTorch](https://pytorch.org/) - GPU support
|
||||
|
||||
Reference in New Issue
Block a user