A chess match can last 4+ hours. As a content creator, you want to turn that into a punchy highlight reel, but manually scrubbing through and identifying key moments is tedious.What if AI could watch the entire match, detect every move, and automatically compile a highlight montage?
from videodb import MediaType# Upload the chess match videochess_video = coll.upload(url="https://www.youtube.com/watch?v=dhDe-RcoyAU")# Upload background music for the montagebg_music = coll.upload( url="https://www.youtube.com/watch?v=S19UcWdOA-I", media_type=MediaType.audio)
Create a scene index with a binary prompt to detect moves:
from videodb import SceneExtractionTypemoves_index_id = chess_video.index_scenes( extraction_type=SceneExtractionType.time_based, extraction_config={"time": 8, "frame_count": 5}, prompt="""Look at this chess scene and focus on the chess board. Your task is to detect when pieces are moved.Respond with ONLY one of these two keywords:- "Player Moved" — if a chess piece was moved- "No Move" — if no move occurred (same position, paused, talking, etc.)Be strict. Only say "Player Moved" if you clearly see a chess piece moved.""", name="Chess_Move_Detection")# Get all scenes with descriptionsmoves_scenes = chess_video.get_scene_index(moves_index_id)
Feed the scene index to the LLM to extract timestamps:
import jsonprompt = f"""Analyze the scene descriptions from this chess video.Find EVERY scene where the description says "Player Moved".Return a JSON array containing ONLY the start timestamps (in seconds) of those scenes.Example output format:[0, 8, 16, 24, 40, 48]Rules:- Return ONLY the JSON array, nothing else- No descriptions, no explanations, just timestampsMoves Index : "{moves_scenes}""""response = coll.generate_text( prompt=prompt, response_type="json", model_name="pro")# Parse timestamps from LLM responsetimestamps = response["output"]if isinstance(timestamps, str): timestamps = json.loads(timestamps)
Initialize timeline and sample moves:
from videodb.editor import ( Timeline, Track, Clip, VideoAsset, AudioAsset, Filter, Transition, TextAsset, Font)CLIP_DURATION = 5 # seconds per clipTARGET_CLIPS = 10 # how many clips we want# Sample timestamps evenlytotal_detected = len(timestamps)step = max(1, total_detected // TARGET_CLIPS)sampled_timestamps = timestamps[::step][:TARGET_CLIPS]# Initialize timelinetimeline = Timeline(conn)timeline.background = "#000000"# Create intro textintro_text = TextAsset( text="Let the Match Begin", font=Font(family="Clear Sans", size=56, color="#FFFFFF"),)intro_clip = Clip( asset=intro_text, duration=3, transition=Transition(in_="fade", out="fade", duration=0.5))intro_track = Track()intro_track.add_clip(0, intro_clip)timeline.add_track(intro_track)
What took hours of manual editing now takes minutes. Your audience gets punchy, professional highlight reels. You get back your time.No more endless scrubbing. Just AI-powered chess analysis and automatic montages.
Explore the Full Notebook
Open the complete implementation with advanced filtering, custom transitions, and batch processing.