Windows App · GPU + CPU ✦ AI-Powered Donation-Based v7.1

SharpMoment
AI

AI-powered video frame extractor that detects subjects and faces, scores sharpness on the person not the background, and evaluates face quality on every candidate. Rewards close-up hero moments and picks one perfect frame per time window — GPU accelerated, 4K ready, no duplicates.

YOLOv8 InsightFace buffalo_l Tenengrad Sharpness FFmpeg CUVID Sliding-Window NMS
4K
AV1 · VP9 · H.264
GPU accelerated
2
Detection modes
Full body · Face only
3
AI models
YOLO · InsightFace · NMS
0
Duplicates
one peak per window
SharpMoment AI — Step 0 Upload and Check Orientation
Step 0 · Upload & Preview

Drop Your Video. See the Subject Detected Instantly.

Upload any 4K, 1080p, or vertical video. SharpMoment AI reads codec metadata, configures GPU hardware decode automatically, and shows you the first non-black frame with a live detection box drawn around the subject. Drag the scrubber to check any frame before running analysis — the YOLO box updates in real time.

  • ✓ Supports MP4, WebM, MOV, MKV, AVI — AV1, VP9, H.264, HEVC codecs
  • ✓ GPU CUVID hardware decode detected and configured automatically
  • ✓ Live YOLO detection box updates as you scrub the preview slider
  • ✓ Rotation correction — 0° / 90°CW / 180° / 90°CCW
  • ✓ Auto-skips black fade-in frames to show the first real content
  • ✓ Full codec info: resolution, FPS, frame count, decoder mode
SharpMoment AI — 4K 60fps AV1 GPU decode detected
GPU CUVID · AV1
4K 60fps AV1 — Fully Hardware Decoded

When running on the GPU build, FFmpeg uses NVIDIA CUVID hardware decoders for AV1, VP9, H.264, HEVC, VP8, and MPEG2. Pass 1 on a 4K AV1 file completes in ~3 minutes. The bundled FFmpeg 7.1.1 static build is pre-verified — no install, no PATH setup required.

SharpMoment AI — Step 1 Configure and Analyse Video
Step 1 · Configure & Analyse

Pass 1: Scan Every Frame. Score Every Subject.

Run Pass 1 once per video. The app scans every frame with YOLOv8, crops the detected subject bbox, measures Tenengrad sharpness on that crop only, and saves the full analysis to a CSV. Four interactive charts give you complete visibility into your footage — sharpness distribution, face closeness spread, score vs size scatter, and a full timeline of every scored frame.

  • ✓ Threaded FFmpeg decode + YOLO inference pipeline — overlapped, no stall
  • ✓ 8,716 frames with valid subject detected in 3m 35s on 4K AV1
  • ✓ Sharpness floor (p20) automatically disqualifies the blurriest 20%
  • ✓ CSV saved to data/ — reload anytime without re-running Pass 1
  • ✓ Face mode: median face height used for self-calibrating closeness bonus
  • ✓ Full stats: sharpness median/std/range, face height, predicted frame counts
SharpMoment AI — Tune Selections panel
Tune Selections · No Re-Run

Dial In Your Settings. Re-Extract Instantly.

After Pass 1, tune all extraction parameters without re-running analysis. The Closeness slider recomputes scores live — the predicted frame count and timeline update in real time as you drag. Run Pass 2 as many times as you like with different settings: more frames, fewer frames, tighter windows, looser thresholds.

  • ✓ Sharpness ◀──▶ Closeness slider — live score recomputation
  • ✓ Top % to keep + NMS window size — predicted count updates instantly
  • ✓ Output Crop — full frame or 2:3 vertical portrait (auto-detects subject)
  • ✓ Subject Padding slider for portrait crop breathing room
  • ✓ Output format JPG or WebP, quality 70–100
  • ✓ Explainer chart shows exactly which frame wins at each slider setting
SharpMoment AI — Step 2 Extract Sharp Frames
Step 2 · Extract Frames

Pass 2: Frame-Accurate Seek. Smart Face Filter.

Pass 2 uses FFmpeg’s select=eq(n,N) filter to seek frames by index — not timestamp arithmetic. Every extracted frame exactly matches what Pass 1 scored. With Smart Face Filter on, InsightFace buffalo_l evaluates 3 candidates per window and picks the one with the highest face quality embedding norm — selecting the sharpest, most forward-facing expression automatically.

  • ✓ 38 frames saved at 4K · JPG q90 in under 3 minutes
  • ✓ Smart Face Filter: 38/38 windows improved by InsightFace quality score
  • ✓ Debug mode: export all 3 candidates with quality scores in filenames
  • ✓ Gallery preview of first 12 extracted frames inline
  • ✓ Open Output Folder button — jumps directly to saved files
  • ✓ Cancel at any point — partial results are saved
🎯
Subject-Aware Sharpness — Not Background Sharpness

Every other tool scores sharpness on the full frame — but a sharp background with a soft subject is useless. SharpMoment AI crops the detected subject bbox before measuring Tenengrad gradient energy. Only the person’s sharpness matters. Tested and confirmed: sharp frames score 1.6–1.9× higher than adjacent blur frames from interpolated 60fps video.

✨
Smart Face Filter — InsightFace Quality Scoring

InsightFace buffalo_l’s ResNet50 recognition model generates a quality embedding for each face candidate. The L2 norm of that embedding naturally captures sharpness, frontal pose, occlusion, and face size in a single learned scalar. Between three candidates per window, the highest norm wins — detecting blur, profile angles, and partial occlusion automatically.

⏱️
Sliding-Window NMS — No Duplicates

Non-Maximum Suppression selects the single highest-scoring frame within each time window, then suppresses all frames within ±window seconds. Dense movement — a dancer making the same pose 12 times — produces exactly one output frame per window slot. Configurable window from 0.5s to 5.0s.

🚀
Threaded GPU Pipeline — 3× Faster

A background thread runs FFmpeg CUVID decode into a bounded queue while the main thread runs YOLO inference. Decode and inference overlap completely — GPU utilisation stays high throughout Pass 1. On 4K AV1 content this cuts Pass 1 time from ~5min (sequential) to ~3min (threaded).

📐
2:3 Vertical Portrait Crop

Pass 2 can re-detect the subject at full resolution and crop a portrait frame automatically. Crop sizing starts from the subject bbox, not the full frame — delivering tight, well-framed portraits at any source resolution. Edge handling uses clamp-and-slide to preserve the 2:3 ratio without shrinking.

🎛️
Sharpness ◀──▶ Closeness Slider

The live scoring slider trades sharpness against subject closeness without re-running Pass 1. At 0.0, the sharpest frame wins regardless of distance. At 1.0, the closest performer wins even if slightly soft. The explainer chart shows the crossover point in real time — the close-up “hero moment” wins exactly where you expect it to.

Three-Pass Architecture — Analyse Once, Extract Many Times
1
Pass 1 — Frame Analysis (Run Once)

FFmpeg CUVID decodes the video to 1920px pipe resolution in a background thread. The main thread runs YOLOv8 on every frame, finds the subject bbox, crops it, and measures Tenengrad sharpness on that crop. In Face only mode, all raw face data is stored and median face height is computed after the full scan — enabling the self-calibrating closeness bonus. Results save to data/videoname_face_analysis.csv next to the exe. Pass 1 never needs to run again unless settings change.

↓
2
Tune Selections — Live Score Recomputation

Combined scores are never baked into the CSV — they’re recomputed from raw sharpness and subject size columns at NMS time using the current Closeness slider value. Moving the slider immediately updates scores, predicted frame count, and the timeline chart. The CSV column is written for human readability only and is never used for ranking. Load a saved CSV anytime and pick up exactly where you left off.

↓
3
Pass 2 — Frame-Accurate Extraction

NMS selects the winning frame indices. FFmpeg seeks each using select=eq(n\,N) — the same sequential counter used by Pass 1’s pipe iterator. No timestamp arithmetic, no fps conversion, no pre-seek. The frame index from Pass 1 maps exactly to frame N in the select filter. This was a critical design decision: timestamp-based seeking was confirmed to land consistently on the wrong frame (frame+1) for VP9 interpolated content.

↓
4
Smart Face Filter (Optional) — InsightFace Quality Pass

When Smart Face Filter is enabled, NMS runs at window/3 to generate 3 candidates per original window slot. All 3 are sought at full resolution and scored by InsightFace buffalo_l. The winner is the candidate with the highest embedding norm — capturing sharpness, frontal pose, and occlusion as a single learned quality signal. In debug mode all 3 candidates are saved with quality scores embedded in filenames so you can audit every decision.

Four Charts — Complete Visibility Into Your Footage

After Pass 1, four matplotlib charts give you a complete view of your footage’s sharpness landscape, subject closeness distribution, score correlations, and the full frame selection timeline. All four are live — adjusting the Closeness slider or NMS settings updates the timeline chart in real time without re-running Pass 1.

Chart 1 — Sharpness Distribution
01
Sharpness Distribution

Histogram of Tenengrad scores across all frames with a valid subject. Reveals how sharp your footage actually is — a narrow peak suggests consistent focus; a long right tail means standout moments exist.

Chart 2 — Face Closeness Distribution
02
Face Closeness Distribution

Face height as % of frame height across all detected faces. Shows performer proximity patterns — the bimodal shape here reveals a mid-distance cluster at 18–20% and a close-up cluster at 25–27%.

Chart 3 — Score vs Subject Size scatter
03
Score vs Subject Size

Scatter plot of face/body closeness against combined score, coloured by sharpness. The bright yellow cluster (top-left) shows sharp close-up moments — your best candidates at any closeness setting.

Chart 4 — Frame Score Timeline with extracted frames
04
Frame Score Timeline

Full video timeline showing every scored frame (grey), NMS threshold (red dashed), predicted selections (orange), and extracted frames (green stars). 38 evenly distributed selections across 2m 40s of footage.

📊 Closeness Slider — See Exactly Which Frame Wins
Chart 5 — Closeness Slider explainer

The explainer chart models two hypothetical frames: a sharp far frame (sharpness=9000, closeness=12%) and a close soft frame (sharpness=5500, closeness=28%). As you drag the slider, the chart updates live to show the crossover point — exactly where the close-up hero moment starts winning over the sharper but more distant frame.

SliderPriorityBest for
0.0Pure sharpnessTechnical quality, fine print, flat stage
0.4Sharpness-biasedMost concert / dance footage (default)
0.65Closeness-biasedFan shots, idol content — hero moments win
1.0Pure closenessClose-ups regardless of blur
InsightFace buffalo_l — Quality, Not Confidence
🧠
Embedding Norm Quality Signal

buffalo_l’s w600k_r50.onnx recognition head was trained on millions of face images. Clean, sharp, forward-facing faces produce high-magnitude embeddings because the model has more discriminative signal. Blurry, angled, or partially occluded faces produce lower norms. Quality range: 15.0–25.0 (higher = better).

❌
Why det_score Doesn’t Work

det_score is detection confidence — it only measures how sure YOLO is that a face exists. All three candidates consistently score 0.7–0.9 with no meaningful spread, making winner selection essentially random. The embedding norm gives clear separation between candidates in the same window.

🔍
What It Captures

Embedding norm captures: face visibility / occlusion, image sharpness on the face region, pose deviation from frontal, and face size. Known limitation: closed-eye detection. A frame with closed eyes but sharp may outscore an identical open-eye frame. Future version will layer in EAR (Eye Aspect Ratio) as a disqualifier.

⚡
3-Candidate Window Logic

Smart Face Filter runs NMS at window/3 internally, generating 3 candidates per original window slot. All 3 are sought at full resolution via GPU CUVID, scored by InsightFace, then the winner is written to disk. Output frame count matches a normal Pass 2 run — quality improves without increasing output volume.

🐛 Debug mode: Enable Debug to export all 3 candidates per window. Winner gets _winner suffix, losers get _qN.NNN quality scores in filenames, no-face detections get _qnone. Audit every decision the algorithm made before committing to a non-debug run.
Any Modern Video Format — GPU Hardware Decoded
CodecContainerGPU DecoderStatus
AV1MP4 · MKV · WebMav1_cuvid ✅ GPU
VP9WebM · MKVvp9_cuvid ✅ GPU
H.264MP4 · MOV · MKVh264_cuvid ✅ GPU
HEVC / H.265MP4 · MOV · MKVhevc_cuvid ✅ GPU
VP8WebMvp8_cuvid ✅ GPU
MPEG-2MPG · TSmpeg2_cuvid ✅ GPU
Any otherAll containersCPU software ⚡ CPU fallback
⚠️ FFmpeg version note: SharpMoment AI bundles FFmpeg 7.1.1 essentials static build from gyan.dev. FFmpeg 8.0.1 is not compatible — a confirmed bug in ffmpeg 8.x’s swscaler refuses nv12→bgr24 conversion for VP9 content with reserved color space metadata, producing zero decoded frames. The bundled version is the correct one to use.
🎬 One-Click Presets for Common Shooting Scenarios
📱
Single Person Vertical
TikTok · Reel · Solo
Top 15%Window 1.0sClosest faceCloseness 0.65

Optimised for vertical video of one performer. Face mode with high closeness weight — rewards hero close-up moments. Min face height 10% ensures realistic face detection thresholds for TikTok footage.

👥
Two Person Horizontal
Half body · Duet
Top 20%Window 1.5sSharpest faceCloseness 0.3

Wider shots with two performers. Sharpest face strategy favours technical clarity. Lower closeness weight prevents either performer’s momentary close-up from dominating selection.

🎭
Group Shot 3+ People
Stage · Concert
Top 25%Window 2.0sSharpest faceCloseness 0.15

Large group stage performances. Max strategy on body mode ensures any sharp subject can win. Very low closeness weight prevents the nearest performer from monopolising all output frames.

💃
Solo Dance Wide Shot
Full body · Dance
Top 20%Window 1.5sClosest faceCloseness 0.4

Single dancer with significant stage movement and distance variation. Balanced closeness weight captures both distant full-body poses and closer detail moments equally.

⚡ Recommended
🎮
GPU Build
~4.4 GB
✓ NVIDIA GPU (RTX 20xx / 30xx / 40xx)
✓ Driver 535.54+ (CUDA 12.4 minimum)
✓ Windows 10/11 x64
✓ PyTorch cu124 · onnxruntime-gpu

Full GPU acceleration for YOLO inference, FFmpeg CUVID hardware decode, and Gradio UI. Pass 1 on 4K AV1 completes in ~3 minutes. Recommended for any machine with a compatible NVIDIA card.

Universal
💻
CPU Build
~1–1.5 GB
✓ Any x64 machine
✓ No NVIDIA GPU required
✓ Windows 10/11 x64
✓ PyTorch CPU · onnxruntime

YOLO inference runs on CPU — ~5–10× slower per frame than GPU, Pass 1 ~8–12 minutes on 4K content. FFmpeg CUVID decode still uses the GPU if available. Works on any Windows machine regardless of GPU model.

What’s Included in the Distribution Zip
📁 SharpMomentAI/
├─ SmartFrameCap.exe ← launcher
├─ ffmpeg.exe ← bundled FFmpeg 7.1.1 static (verified)
├─ _internal/ ← all dependencies (exe + _internal must stay together)
├─ data/ ← created on first Pass 1 run (CSVs)
├─ yolov8n.pt ← auto-downloaded on first body mode use
└─ face_yolov8n.pt ← auto-downloaded on first face mode use
No Python installation required — fully self-contained
FFmpeg 7.1.1 bundled and verified — no PATH setup needed
YOLOv8 models auto-download to script directory on first use
InsightFace buffalo_l models auto-download to ~/.insightface/
CSV data saved next to exe — never inside _internal/
Opens at http://127.0.0.1:7860 in your default browser
🔧 Technical Specifications
🧮
Sharpness Metric

Tenengrad: mean(Sobel_x² + Sobel_y²) on subject bbox crop at 1920px pipe resolution. Confirmed: sharp frames score 1.55–1.82× higher than adjacent blur frames on VP9 60fps interpolated content.

🎯
YOLO Detection

YOLOv8n for body/person detection, face_yolov8n.pt (Bingsu/adetailer) for face detection. Confidence threshold 0.4 for Pass 1 scoring, 0.25 for preview. Auto GPU/CPU device detection at startup.

📏
Resolution Handling

Source at or below 1920px runs at native resolution — never upscaled. 4K downscales to 1920px for YOLO (4× faster). Crop output taken from full-resolution sought frames — no quality loss at output.

📊
Scoring — Face Mode

score = sharpness × (1−cw) + (face_h / median_face_h) × cw × median_sharpness. The face height bonus is normalised against the video’s own median — self-calibrating across any venue or camera distance.

📐
Scoring — Body Mode

score = sharpness × ((1−cw) + cw × log_curve(body_area%)). Log curve: max(0.1, log1p(x) / log1p(50) × 1.7). At 5% area: ×0.70; at 20%: ×1.30; at 50%: ×1.70.

🔐
Frame Seeking

Pass 2 uses select=eq(n\,N) FFmpeg filter — no timestamp arithmetic, no pre-seek, 120s timeout for long GOP VP9/AV1. The frame index from Pass 1’s sequential pipe counter maps exactly to n=N in the select filter.

🚀 Up and Running in Under a Minute
1
Donate

Support the project via Ko-fi or Buy Me a Coffee.

2
Run SmartFrameCap.exe

Double-click SmartFrameCap.exe. A console window shows startup info — YOLO device (GPU/CPU), FFmpeg path, and GPU CUVID status. The Gradio UI opens automatically at http://127.0.0.1:7860.

3
Upload Your Video & Choose a Preset

Drop your video in Step 0. Preview the detection box — adjust rotation if needed. Switch to Face only mode for dance/idol content. Select a preset from the dropdown. YOLOv8 models download automatically on first use.

4
Run Pass 1 — Wait for Analysis

Click ▶ Run Pass 1. Watch the progress bar and ETA. Charts fill in as Pass 1 completes. The CSV saves automatically — you can reload it later without re-running. Pass 1 runs once per video.

5
Tune & Extract

Adjust the Closeness slider, Top %, and Window Size in the Tune Selections section. Enable Smart Face Filter for quality-scored extraction. Click ▶ Run Pass 2 — extracted frames appear in the gallery. Open Output Folder to access your files.

Licensing & Donation Model

SharpMoment AI uses YOLOv8 (AGPL-3.0) and InsightFace buffalo_l (MIT). Under AGPL-3.0, distributing a closed-source commercial build without purchasing an Ultralytics commercial license is not permitted. SharpMoment AI is therefore available on a donation basis only — not for sale. The donation model is fully compliant with AGPL-3.0.

YOLOv8n — Ultralytics AGPL-3.0
face_yolov8n.pt — Bingsu/adetailer (open weights)
InsightFace buffalo_l — MIT
FFmpeg 7.1.1 — LGPL / GPL (static build)
Gradio — Apache 2.0
PyTorch — BSD-style

DONATION-BASED · NO SUBSCRIPTION · WINDOWS

Support SharpMoment AI

SharpMoment AI is the result of months of research into frame-accurate seeking, VP9 codec quirks, InsightFace quality signals, and GPU pipeline optimisation. Every bug you don’t hit was a debugging session that happened. Your donation funds continued development and maintenance.

🎯
Eye-open detection: EAR from InsightFace landmarks as a hard disqualifier for closed eyes
⚡
Pass 2 sequential optimisation: sort selected frames ascending, single FFmpeg scan instead of per-frame seeks
🌱
Pass 3: post-process extracted frames with background removal, colour grade, and auto-export to social ratios

One-time · Any amount · Download link sent after donation · No subscription

Built with ❤️ by IMGLAB
Ko-fi  ·  Buy Me a Coffee  ·  [email protected]