- 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
64 lines
2.0 KiB
Python
64 lines
2.0 KiB
Python
import json
|
|
import argparse
|
|
from moviepy.editor import VideoFileClip, concatenate_videoclips
|
|
import logging
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
def create_summary(video_file, highlights_file, output_file, padding=5):
|
|
"""Crea video resumen con los highlights"""
|
|
|
|
# Cargar highlights
|
|
with open(highlights_file, 'r') as f:
|
|
highlights = json.load(f)
|
|
|
|
if not highlights:
|
|
print("No hay highlights")
|
|
return
|
|
|
|
# Filtrar highlights con duración mínima
|
|
highlights = [(s, e) for s, e in highlights if e - s >= 5]
|
|
|
|
print(f"Creando video con {len(highlights)} highlights...")
|
|
|
|
clip = VideoFileClip(video_file)
|
|
duration = clip.duration
|
|
|
|
highlight_clips = []
|
|
for start, end in highlights:
|
|
start_pad = max(0, start - padding)
|
|
end_pad = min(duration, end + padding)
|
|
|
|
highlight_clip = clip.subclip(start_pad, end_pad)
|
|
highlight_clips.append(highlight_clip)
|
|
print(f" Clip: {start_pad:.1f}s - {end_pad:.1f}s (duración: {end_pad-start_pad:.1f}s)")
|
|
|
|
if not highlight_clips:
|
|
print("No se pudo crear ningún clip")
|
|
return
|
|
|
|
print(f"Exportando video ({len(highlight_clips)} clips, {sum(c.duration for c in highlight_clips):.1f}s total)...")
|
|
|
|
final_clip = concatenate_videoclips(highlight_clips, method="compose")
|
|
|
|
final_clip.write_videofile(
|
|
output_file,
|
|
codec='libx264',
|
|
audio_codec='aac',
|
|
fps=24,
|
|
verbose=False,
|
|
logger=None
|
|
)
|
|
|
|
print(f"¡Listo! Video guardado en: {output_file}")
|
|
|
|
if __name__ == "__main__":
|
|
parser = argparse.ArgumentParser()
|
|
parser.add_argument("--video", required=True, help="Video file")
|
|
parser.add_argument("--highlights", required=True, help="Highlights JSON")
|
|
parser.add_argument("--output", required=True, help="Output video")
|
|
parser.add_argument("--padding", type=int, default=5, help="Padding seconds")
|
|
args = parser.parse_args()
|
|
|
|
create_summary(args.video, args.highlights, args.output, args.padding)
|