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:
109
pipeline.sh
Executable file
109
pipeline.sh
Executable file
@@ -0,0 +1,109 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Highlight Detector Pipeline con Modo Draft
|
||||
# Uso: ./pipeline.sh <video_id> [output_name] [--draft | --hd]
|
||||
|
||||
set -e
|
||||
|
||||
# Parsear argumentos
|
||||
DRAFT_MODE=false
|
||||
VIDEO_ID=""
|
||||
OUTPUT_NAME="highlights"
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--draft)
|
||||
DRAFT_MODE=true
|
||||
shift
|
||||
;;
|
||||
--hd)
|
||||
DRAFT_MODE=false
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
if [[ -z "$VIDEO_ID" ]]; then
|
||||
VIDEO_ID="$1"
|
||||
else
|
||||
OUTPUT_NAME="$1"
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$VIDEO_ID" ]; then
|
||||
echo "Uso: $0 <video_id> [output_name] [--draft | --hd]"
|
||||
echo ""
|
||||
echo "Modos:"
|
||||
echo " --draft Modo prueba rápida (360p, menos procesamiento)"
|
||||
echo " --hd Modo alta calidad (1080p, por defecto)"
|
||||
echo ""
|
||||
echo "Ejemplo:"
|
||||
echo " $0 2701190361 elxokas --draft # Prueba rápida"
|
||||
echo " $0 2701190361 elxokas --hd # Alta calidad"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "============================================"
|
||||
echo " HIGHLIGHT DETECTOR PIPELINE"
|
||||
echo "============================================"
|
||||
echo "Video ID: $VIDEO_ID"
|
||||
echo "Output: $OUTPUT_NAME"
|
||||
echo "Modo: $([ "$DRAFT_MODE" = true ] && echo "DRAFT (360p)" || echo "HD (1080p)")"
|
||||
echo ""
|
||||
|
||||
# Determinar calidad
|
||||
if [ "$DRAFT_MODE" = true ]; then
|
||||
QUALITY="360p"
|
||||
VIDEO_FILE="${OUTPUT_NAME}_draft.mp4"
|
||||
else
|
||||
QUALITY="best"
|
||||
VIDEO_FILE="${OUTPUT_NAME}.mp4"
|
||||
fi
|
||||
|
||||
# 1. Descargar video
|
||||
echo "[1/5] Descargando video ($QUALITY)..."
|
||||
if [ ! -f "$VIDEO_FILE" ]; then
|
||||
streamlink "https://www.twitch.tv/videos/${VIDEO_ID}" "$QUALITY" -o "$VIDEO_FILE"
|
||||
else
|
||||
echo "Video ya existe: $VIDEO_FILE"
|
||||
fi
|
||||
|
||||
# 2. Descargar chat
|
||||
echo "[2/5] Descargando chat..."
|
||||
if [ ! -f "${OUTPUT_NAME}_chat.json" ]; then
|
||||
TwitchDownloaderCLI chatdownload --id "$VIDEO_ID" -o "${OUTPUT_NAME}_chat.json"
|
||||
else
|
||||
echo "Chat ya existe"
|
||||
fi
|
||||
|
||||
# 3. Detectar highlights (usando GPU si está disponible)
|
||||
echo "[3/5] Detectando highlights..."
|
||||
python3 detector_gpu.py \
|
||||
--video "$VIDEO_FILE" \
|
||||
--chat "${OUTPUT_NAME}_chat.json" \
|
||||
--output "${OUTPUT_NAME}_highlights.json" \
|
||||
--threshold 1.5 \
|
||||
--min-duration 10
|
||||
|
||||
# 4. Generar video
|
||||
echo "[4/5] Generando video..."
|
||||
python3 generate_video.py \
|
||||
--video "$VIDEO_FILE" \
|
||||
--highlights "${OUTPUT_NAME}_highlights.json" \
|
||||
--output "${OUTPUT_NAME}_final.mp4"
|
||||
|
||||
# 5. Limpiar
|
||||
echo "[5/5] Limpiando archivos temporales..."
|
||||
if [ "$DRAFT_MODE" = true ]; then
|
||||
rm -f "${OUTPUT_NAME}_draft_360p.mp4"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "============================================"
|
||||
echo " COMPLETADO"
|
||||
echo "============================================"
|
||||
echo "Video final: ${OUTPUT_NAME}_final.mp4"
|
||||
echo ""
|
||||
echo "Para procesar en HD después:"
|
||||
echo " $0 $VIDEO_ID ${OUTPUT_NAME}_hd --hd"
|
||||
Reference in New Issue
Block a user