Gameplay Clip Extractor
Reduce a 1-hour gameplay capture to a list of 10-second clips worth posting.
When to use
- User has raw
.mp4/.movgameplay footage (their own, no piracy). - User wants timestamps for highlights without scrubbing manually.
- User wants the actual clipped files written to disk.
Detection signals (combine, don't pick one)
1. Audio peak detection (cheapest, works everywhere)
Gunfire, goal whistles, killstreak voice lines, crowd reactions — all show up as audio amplitude spikes.
ffmpeg -i raw.mp4 -af "silencedetect=noise=-30dB:d=0.5" -f null - 2>&1 \
| grep silence_end
Use the inverse — long non-silent stretches with sudden RMS jumps are candidates.
Python (cleaner):
import librosa, numpy as np
y, sr = librosa.load("raw.mp4", sr=22050, mono=True)
rms = librosa.feature.rms(y=y, frame_length=2048, hop_length=512)[0]
peaks = np.where(rms > rms.mean() + 2 * rms.std())[0]
peak_times = librosa.frames_to_time(peaks, sr=sr, hop_length=512)
2. Scoreboard / kill-feed OCR (game-specific, higher accuracy)
- BGMI / COD: top-right kill feed → run Tesseract on that ROI every 1s.
- FIFA: scoreboard score-change → diff frames at fixed coords.
- Cache last value; emit event only on change.
3. Pacing heuristic
Cluster nearby peaks (within 3s) into single moments. A real highlight is usually 1 spike, not a noise burst.
Output
[
{"start": 142.3, "end": 152.8, "label": "kill burst (3 audio peaks)", "score": 0.82},
{"start": 384.1, "end": 394.6, "label": "score change 1→2", "score": 0.95}
]
Then clip with FFmpeg:
ffmpeg -ss 142.3 -i raw.mp4 -t 10.5 -c copy clips/clip_001.mp4
Heuristics for "is this postable?"
- ≥ 2 audio peaks in a 10s window
- Clip ends on a resolved moment (kill confirmed, goal scored), not mid-action
- No long static frames (loading, respawn screen)
What NOT to do
- Don't auto-publish. Always present clips for human review.
- Don't OCR the entire frame — that's slow and noisy. Define ROIs per game.
- Don't process clips you don't own the rights to.