Video Auto-Labeling Pipeline

Automated video segmentation using visual boundary detection, AI transcript classification, and AWS serverless architecture. Configurable for any video type β€” broadcasts, lectures, sports, podcasts, and more.

AWS Lambda Step Functions OpenCV Bedrock Claude React Amplify

Project Overview

This system automatically segments video content by detecting visual boundaries, transcribing audio, and classifying segments using AI. It supports configurable segment types and detection methods, making it adaptable to any video domain β€” from broadcasts to lectures to live events.

πŸ”

Visual Boundary Detection

A trained per-source model classifies frames as commercial or content, with black-frame analysis as an automatic fallback β€” configurable per video source.

🧩

AI Classification

Claude classifies segments by analyzing transcripts with configurable segment type vocabularies.

🎬

Interactive Results

React web application for viewing, editing, and validating segmentation results with timeline visualization and video playback.

Visual Data Algorithms

Black-frames (Fallback Method)

Used when no trained model is available for a video's source, or when the model finds nothing. Black frames inserted at segment boundaries are detected, then paired into segments.

Step 1: Black Frame Detection (Worker)

Each 60-second chunk is analyzed for black frame runs using color histogram comparison:

1. Compute 32-bin color histogram for each frame (RGB channels)
2. Calculate chi-squared distance from a pure-black reference histogram
3. If distance < 0.3 β†’ confirmed black frame
4. If distance < 8.0 β†’ suspicious (may be very dark scene)
5. Refine coarse detections to frame-accurate start/end timestamps

For normal chunks, a coarse 1fps scan finds candidates, then a frame-by-frame refinement pass in Β±2s windows determines precise boundaries. Short probe windows (≀15s) use frame-by-frame scanning directly.

Step 2: Event Extraction (Merger)

Black frame runs from all chunks are merged and converted into discrete "events":

1. Merge adjacent runs across chunk boundaries (gap < 0.1s)
2. Filter runs shorter than 0.1s (noise)
3. Extract events: runs separated by β‰₯15 seconds become distinct events
4. Remove events in first 5 minutes and last 60 seconds (margins)

Step 3: Segment Pairing (Merger)

Events are paired into segments using duration heuristics:

1. For each unpaired event, find the best partner where:
   - Duration is between 90s and 300s (1.5 to 5 minutes)
   - Duration is closest to a standard multiple of 30s
2. Remove "interior" events (black frames within paired segments)
3. Re-pair after cleanup
4. Probe for missing partners at standard offsets (30s, 60s, ..., 300s)
5. Short segments (<90s) β†’ attempt to extend from endpoints
6. Final cleanup: merge overlaps, remove contained segments

Key Design Decisions

  • Configurable margin: Start/end margins are skippable (default: first 300s skipped for pre-content)
  • Histogram-based detection: More robust than simple pixel averaging β€” handles noise, compression artifacts, and near-black scenes
  • Standard duration matching: Segments are paired using expected duration multiples, providing a strong pairing heuristic
  • Active probing: When events can't be paired from the initial scan, targeted Lambda invocations search for missing partners at expected offsets
  • 60-second chunks: Balances Lambda execution time against parallelism and Step Functions event limits

Model-Based Detection (Primary Method)

The primary visual detection method, used for videos that don't have reliable black frames between segments. Instead of looking for black frames, a trained classifier decides frame by frame whether the frame is commercial or content β€” typically by learning the pixels where a persistent ticker, logo, or overlay sits. Each video source gets its own model.

🧠

Trained Per Source

A logistic regression trained on ground-truth-labeled video from that source, stored as a pickled model in S3 and selected by the source ID in the filename.

🎯

Learns Where to Look

Training ranks every pixel channel by how reliably it tells commercial from content, then keeps only the few hundred that rank highest β€” so classifying a frame is cheap.

⚑

Single-Pass Scan

Processes the entire video in one pass at configurable frame rate (0.5–1 fps), grouping consecutive commercial frames into segments.

πŸ”„

Automatic Fallback

If no model exists for the source, or the model finds zero segments, the system automatically falls back to the black-frame method.

How It Works

1. Sample frames at the configured scan rate (0.5–1 fps)
2. Resize each frame to the model's training resolution (default 64Γ—36) and convert to HSV
3. Read only the pixel positions the model selected during training
4. Scale those values and score them β†’ commercial probability
5. If probability > threshold β†’ frame is commercial
6. Group consecutive commercial frames into segments
7. Filter: drop strays (<10s), merge nearby segments (<10s gap), drop segments <20s
8. Skip configurable margin at start and end

Per-Source Configuration

Each video source has its own model and settings stored in S3, configured via a JSON file:

{
  "SOURCE_A": {
    "model_threshold": 0.5,        // Commercial probability cutoff
    "scan_fps": 0.5,               // Frames per second to sample
    "profile_key": "config/profiles/SOURCE_A_model.pkl"
  }
}

Threshold tuning: lower = more detections (more false positives), higher = fewer detections. A source with no entry here falls back to black-frame detection rather than being scored by another source's model. The model must match the era and visual style of the video content.

Training a Model

Models are trained offline from ground-truth-labeled videos. The trainer:

1. Load ground truth CSV with labeled segments (commercial vs content)
2. Sample frames at 1 fps from each labeled segment, resize and convert to HSV
3. Score every pixel channel by Fisher criterion:
     (mean_commercial - mean_content)Β² / (var_commercial + var_content)
4. Keep the ~500 pixel channels with the highest scores
5. Fit a logistic regression on just those pixels
6. Save as .pkl β†’ upload to S3

Training also writes an importance map image showing which pixels the model relies on, overlaid on a real frame β€” a quick way to confirm it locked onto the persistent graphic rather than something incidental.

Detection Routing

The video dispatcher sends every video to the model-based detector, which decides whether it can handle it:

Video uploaded β†’ Dispatcher β†’ Model-Based Detection
  β†’ No source ID in filename        β†’ Black-Frame Detection
  β†’ No model configured for source   β†’ Black-Frame Detection
  β†’ Model file missing from S3       β†’ Black-Frame Detection
  β†’ Model ran, found 0 segments      β†’ Black-Frame Detection
  β†’ Otherwise β†’ segments written directly

Transcription & AI Segmentation

This part of the automated pipeline uses the visual detection output as input to an AI-powered transcript segmentation system. This identifies individual content segments within the non-break portions of each video.

How It Works

1

Video Transcription

AWS Transcribe Lambda

Uploads trigger automatic transcription via AWS Transcribe, producing word-level timestamps for the entire video. Output: JSON with every word and its precise start/end time.

↓
2

Commercial Filtering

Python (filter_commercials.py)

Uses the _segments.json output from the Visual Segment Detector to remove all words that fall within detected break segments. Inserts [ BREAK ] markers as hard boundaries.

↓
3

AI Segmentation

Amazon Bedrock (Claude Sonnet)

The filtered transcript is sent to Claude via Pydantic AI. The model identifies content segment boundaries by detecting topic changes, speaker handoffs, and transitions. Returns structured segment data with verbatim first/last sentences.

↓
4

Timestamp Matching

Python (timestamp_matcher.py)

Maps the AI-identified segment boundaries (first/last sentences) back to precise video timestamps using the original word-level transcription data. Produces frame-accurate start/end times for each content segment. Output: ai_results/{video}_segments.json

↓
5

Sub-Segment Detection

Amazon Bedrock (Claude) + Python

Loads visual segments and AI segments, merges them into a unified timeline, and uses Claude to detect transition speech at content→break boundaries. Output: subsegment_results/{video}_with_subsegments.json

↓
6

Evaluation

Python (evaluation_metrics.py)

Compares predicted segments against human-annotated ground truth using frame accuracy, segment F1 at multiple IoU thresholds, boundary F1 at multiple tolerances, and normalized edit distance.

↓
7

Results Merger

Python + Boto3

Uses the sub-segment JSON as the authoritative timeline. Enriches content segments with titles from AI segmentation and full transcripts from the transcription bucket. Output: result/{video}.json

Connection Between Detectors

Visual Segment Detector

Outputs: segment_results/{video}_segments.json

Visual analysis β†’ break segment timestamps

β†˜

AI Segmentation

Outputs: ai_results/{video}_segments.json

Claude transcript analysis β†’ content segment boundaries

AI Segmentation Approach

The system uses Claude (via Amazon Bedrock) with a carefully crafted archival prompt that instructs the model to:

  • Respect hard boundaries: [ BREAK ] markers are absolute β€” no segment spans across them
  • Identify natural transitions: Speaker handoffs, topic changes, and shifts in focus
  • Extract verbatim sentences: First and last sentences of each segment are extracted word-for-word for precise timestamp matching
  • Maintain continuity: Panel discussions that shift topics stay as one segment; same-story coverage across speakers stays unified
  • Complete coverage: Every part of the transcript must be assigned to a segment with no gaps

Frontend Application

The web application is built with React + TypeScript + Vite, deployed on AWS Amplify Gen 2.

Technology Stack

Framework: React 18 + TypeScript
Build: Vite
Hosting: AWS Amplify
Auth: Cognito (email login)
Storage: S3 via Amplify Storage
API: AppSync GraphQL

Key Pages

πŸ“Ή Video Select

Browse and search all available videos from S3 storage. Preview video before selecting for analysis.

🎬 Results Viewer

Interactive visualization of segmentation results with a color-coded timeline. Click segments to jump to that point in the video. Supports editing segment boundaries, adding/removing segments, and merging adjacent segments.

✏️ Edit Mode

Users can enter edit mode to correct segmentation errors: drag timeline markers, inline-edit timestamps, change segment type labels, merge segments, or add new ones. Edits save back to S3 as JSON.

Segment Types (Configurable)

C Content
B Break
T Transition
I Intro
O Outro

Segment types, colors, and labels are fully configurable in src/utils/segment_types.ts to match your domain.

Cost & Performance

Per 1-hour video:
β”œβ”€β”€ Video processing (detection of visual clues to content): free-tier Lambda or ~$0.035/10 videos           
β”œβ”€β”€ Transcription (AWS Transcribe): ~$0.72, 3-5 min
β”œβ”€β”€ AI Segmentation (Bedrock Claude): ~$0.60-$0.80, 2-4 min
└── Evaluation: ~$0.01, 30 sec
Total: ~$1.50, 6-10 minutes end-to-end

Backend Architecture

The processing pipeline runs entirely on AWS serverless infrastructure, deployed with SAM (Serverless Application Model).

1

Batch Orchestrator

Shell Script + AWS CLI

Lists all .mp4 videos in S3, groups them into batches of 20 (to stay under Step Functions' 25K event limit), and invokes the Launcher Lambda for each batch.

↓
2

Launcher Lambda

Python + Boto3

Scans the S3 bucket for video files, builds chunk definitions (each video divided into 60-second chunks starting at the 5-minute mark), and starts a Step Functions execution.

↓
3

Step Functions State Machine

AWS Step Functions (Nested Map)

Orchestrates parallel processing: outer Map iterates videos (20 concurrent), inner Map iterates chunks per video (40 concurrent workers). Includes retry logic with exponential backoff.

↓
4

Worker Lambda

Python + OpenCV (Docker, ARM64)

Reads a 60-second chunk of video via presigned URL. Performs coarse 1fps black frame scan, then refines detections to frame-accurate boundaries. Returns timestamped black frame runs.

↓
5

Merger Lambda

Python + Boto3

Collects all chunk results, merges adjacent runs, extracts discrete events, pairs them into segments, probes for missing partners, and writes final results to S3 and DynamoDB.

Infrastructure Resources

S3 Bucket

Stores source videos (video/) and processing results (result/).

DynamoDB Tables

Three tables: chunk results, per-video segment results (video_name + timestamp), and evaluation summaries.

Lambda Functions

Containerized (Docker) on ARM64. Worker: 2GB RAM, 5 min timeout. Merger: 512MB, 15 min timeout. Launcher: 256MB, 1 min.

Step Functions

Standard workflow with nested Map states. Processes up to 800 chunks concurrently (20 videos Γ— 40 chunks).

Serverless Deployment

The pipeline deploys as event-driven Lambda functions connected by S3 triggers:

Upload video to S3
  β†’ [S3 trigger] β†’ Transcription Lambda (AWS Transcribe)
  β†’ [S3 trigger] β†’ Visual Segment Detector
    β†’ [Readiness Checker] β†’ AI Segmentation (Bedrock Claude)
      β†’ ai_results/{video}_segments.json
        β†’ [S3 trigger] β†’ Sub-Segment Detector
          β†’ subsegment_results/{video}_with_subsegments.json
            β†’ [S3 trigger] β†’ Results Merger
              β†’ result/{video}.json β†’ Web UI

End-to-End Data Flow

πŸ“€

1. Video Upload

Video files (.mp4) are uploaded to S3

⚑

2. Parallel Processing of Visual Data

Step Functions fans out: up to 800 concurrent Worker invocations scanning for black frames in 60s chunks or searches for distinctive visual features in selected region of videos.

Merger Lambda collects results, pairs black frame events into segments, probes for missing boundaries

πŸ’Ύ

3. Store Segment Results

Detected visually distinct segments written to S3 (segment_results/{video}_segments.json) and DynamoDB.

πŸ“

4. Transcription & AI Segmentation

Videos are transcribed (AWS Transcribe), visually distinct segments can be filtered out, and Claude identifies individual content segment boundaries. Output: ai_results/{video}_segments.json

🎯

5. Sub-Segment Detection

Sub-Segment Detector loads visual and AI segments, merges into a unified timeline, and detects transition speech at content→break boundaries. Output: subsegment_results/{video}_with_subsegments.json

🌐

6. Visualization

Staff access the web app, select a video, view detected segments on an interactive timeline, and correct any errors

βœ…

7. Validation

Human-corrected annotations saved back to S3 to be sent to database to augment discoverability.

Demo

Watch the pipeline in action β€” this video demonstrates the full segmentation workflow from upload through final labeled results of our tool as used by the Vanderbilt Television News Archive.

About

Vanderbilt Cloud Innovation Lab

The Vanderbilt Cloud Innovation Lab, housed at the Jean and Alexander Heard Libraries and powered by Amazon Web Services, provides immersive experiences for Vanderbilt University students who are interested in learning how to use artificial intelligence and cloud technologies to develop advancements in digital scholarship. Under the mentorship of AWS and library staff experts, students not only gain important career skills by collaborating on open-source technology but also have meaningful opportunities to enact lasting, positive change. Their innovative solutions to today's real-life challenges ensure that the world's cultural heritage is preserved and accessible for the benefit of future generations.

Students are involved in every stage of a Vanderbilt Cloud Innovation Lab project and learn a variety of career competencies in the process: experiential problem solving, critical thinking, project management, agile development, technical skills, and time management.

Meet the Team

Oybek

Oybek

Sophomore at Vanderbilt majoring in Computer Science, from Tashkent, Uzbekistan. Background in front-end development with React Native and cybersecurity.

Brian

Brian

Passionate about creative solutions to technical problems. Experience with Vanderbilt Library Special Collections and University Archives. Active with the Vanderbilt Robotics team.

Wasi

Wasi Hussain

Computer Science major focused on the intersection of cloud computing and machine learning. Recent work on improving energy efficiency of large language models.

Rithika

Rithika Thambireddy

Computer Science and Mathematics student. Experience spanning AI/ML, data engineering, and full-stack development. Driven to build inclusive and accessible tools.

Abbie

Abbie Chen

Senior studying Computer Science at Vanderbilt University.