ai newsDi., 1. Dez.
EilmeldungThe Model Proposes, Your Code Disposes: A Tool-Calling Agent Loop for Android with Gemini Nano

KI-Sport-Highlights in Echtzeit für die WM 2026 bauen

Fans erwarten sekundenschnell nach einem Tor einen Clip für TikTok, nicht erst nach dem Abpfiff. Der Beitrag beschreibt einen Cloud-nativen Blueprint für die Erstellung solcher Highlights in Echtzeit mit KI.

dev.toMontag 06:55 · 30.11.DE4 Min. Lesezeit
Bild: dev.to

Fans are no longer willing to wait for the final whistle to relive the action. Within seconds of a goal, a TikTok‑ready clip is expected. Google Trends shows a 150 % surge in searches for “AI highlights” and “instant match summary” since the 2026 World Cup, proving that the market is screaming for automation.

This guide shows you exactly how to build a production‑grade, cloud‑native pipeline that ingests live sports feeds, detects key events, and spits out polished, platform‑specific videos in under five seconds. No fluff—just the commands, code snippets, and architecture decisions you need to start shipping highlights today.

flowchart TD A[Live RTMP/UDP Stream] --> B[Ingest Service (Kafka + S3)] B --> C[Frame Decoder (FFmpeg)] C --> D[Multimodal Detector (YOLO‑v8 + VGGish)] D --> E[Event Router (FastAPI + Redis)] E --> F[Clip Builder (FFmpeg + Runway Gen‑2)] F --> G[Post‑Process (Watermark, Transcode)] G --> H[CDN Distribution (Cloudflare + S3)] Ingest – Kafka topics store raw HLS chunks; S3 acts as the immutable archive. Detection – A GPU‑accelerated YOLO‑v8 model (objects) + VGGish (audio) runs on a K8s pod with NVIDIA T4. Orchestration – FastAPI receives detection events, writes them to Redis, and triggers a background worker.

Clip Generation – FFmpeg extracts the relevant segment, then Runway Gen‑2 adds transitions and AI‑generated crowd graphics. Delivery – Final MP4 is uploaded to S3, invalidates Cloudflare cache, and is instantly available for Shorts, TikTok, or OTT. Step‑by‑Step Implementation 1.

Spin up the Kubernetes cluster (Terraform) provider "aws" { region = "us-east-1" } module "eks" { source = "terraform-aws-modules/eks/aws" cluster_name = "sports-highlights" cluster_version = "1.30" node_groups = { spot = { desired_capacity = 2 max_capacity = 5 instance_type = "t3.large" spot_price = "0.012" } } } Enter fullscreen mode Exit fullscreen mode Spot instances keep GPU costs down by ≈ 80 %.

helm repo add huggingface https://huggingface.github.io/helm-charts helm install yolo inference/huggingface \ --set model.name=ultralytics/yolov8x \ --set resources.limits.nvidia.com/gpu=1 \ --set replicaCount = 2 Enter fullscreen mode Exit fullscreen mode The same chart can be used for VGGish by swapping the model.name.

import cv2, torch, redis, json from vggish import VGGish from yolov8 import YOLOv8 video = cv2. VideoCapture ( "s3://bucket/live/stream.m3u8" ) yolo = YOLOv8 ( "ultralytics/yolov8x" ) audio = VGGish ( ) rdb = redis. StrictRedis ( host = "redis", port = 6379 ) while True: ret, frame = video. read ( ) if not ret: break # visual detection boxes, scores, classes = yolo. predict ( frame ) # audio detection (simple 1‑sec buffer) audio_feat = audio. extract ( frame ) # placeholder if audio_feat. contains ( "crowd_cheer" ): event = "goal" # combine signals if any ( c == "ball" and s > 0.9 for c, s in zip ( classes, scores ) ): event = "shot" if event: payload = { "event": event, "timestamp": video. get ( cv2.

CAP_PROP_POS_MSEC ) } rdb. publish ( "events", json. dumps ( payload ) ) Enter fullscreen mode Exit fullscreen mode The script runs in a dedicated pod with --gpus all and pushes JSON events to Redis.

from fastapi import FastAPI import redis, json, subprocess app = FastAPI ( ) r = redis. Redis ( host = "redis", port = 6379 ) def build_clip ( event: dict ): start = max ( event [ "timestamp" ] - 3000, 0 ) # 3 s before duration = 8000 # 8 s total cmd = [ "ffmpeg", "-y", "-ss", f "{start/1000}", "-i", "s3://bucket/live/stream.m3u8", "-t", f "{duration/1000}", "-c:v", "libx264", "-preset", "fast", "-c:a", "aac", f "/tmp/{event['event']}_{event['timestamp']}.mp4" ] subprocess. run ( cmd, check = True ) # optional Runway Gen‑2 call (REST API) #... # upload to S3 subprocess. run ( [ "aws", "s3", "cp", f "/tmp/{event['event']}_{event['timestamp']}.mp4", f "s3://highlights/{event['event']}/{event['timestamp']}.mp4" ] ) @app. on_event ( "startup" ) def subscribe ( ): pubsub = r. pubsub ( ) pubsub. subscribe ( "events" ) for message in pubsub. listen ( ): if message [ "type" ]!= "message": continue event = json. loads ( message [ "data" ] ) build_clip ( event ) Enter fullscreen mode Exit fullscreen mode FastAPI runs as a stateless service; scaling is handled by the K8s HPA based on Redis queue length.

# watermark & format conversion (runs in a side‑car container) ffmpeg -i input.mp4 -vf "drawtext=text='Live Highlights':x=10:y=H-30:fontsize=24:fontcolor=white" \ -c:a copy -movflags +faststart output.mp4 # upload & purge aws s3 cp output.mp4 s3://highlights/shorts/ curl -X POST "https://api.cloudflare.com/client/v4/zones/<ZONE_ID>/purge_cache" \ -H "Authorization: Bearer $CF_TOKEN" \ -H "Content-Type: application/json" \ --data '{"files":["https://cdn.example.com/highlights/shorts/output.mp4"]}' Enter fullscreen mode Exit fullscreen mode The final MP4 is ready for YouTube Shorts (9:16), TikTok, or any OTT player in under five seconds from the original event.

Originaltitel: Build Real‑Time AI Sports Highlights for the 2026 World CupQuelle: dev.to (dev.to). Original öffnen