name: avideos description: Use when the user says 'AVideos' or asks for a reel/video from their photos and videos: score quality, pick the best moments, show a storyboard, render only after approval.
What does avideos do?
Make a reel the way an editor does: watch everything first, score the quality, choose only the best moments, show the choices, render only after the user approves.
Hard rules
- NO captions, NO text overlays, NO titles unless the user asks for them.
- NO final render before the user approves the storyboard.
- No music unless asked. Deliver with a silent audio track and tell the user to add a trending song in Instagram/TikTok.
- Never use a rejected moment (see Step 3) just to fill time.
- Quality first. A slot with no strong moment is removed, not filled. A shorter reel with only strong cuts beats a longer one with one weak cut.
- Default output: vertical 1080x1920, 30 fps, H.264. Target 15–30 s unless the user says otherwise.
- Reply in the user's language.
Step 1 — Inventory
- List every file: type, duration, resolution, orientation (respect EXIF and rotation side data), date taken.
- Find duplicates (same file sent twice, near-identical photos). Compare frames, not file names or sizes. Keep the best one only.
- Mark low-resolution files (short side under 1000 px) as "use only if needed".
- A "photo" with black bars at phone-screen size is usually a screenshot of a video. Ask the user for that video.
Step 2 — Watch the videos (really look)
For each video:
- Scene changes:
ffmpeg -i in.mp4 -vf "select='gt(scene,0.25)',showinfo" -f null -and note the timestamps. - Frames every 0.5 s at small size, tiled into contact sheets (
fps=2,scale=240:-1,tile=8x4), with the timestamp on each frame (drawtext pts). Look at every sheet. Do not skip any part of a video. - Measure each second with Python (OpenCV/numpy):
- sharpness = Laplacian variance (reject the blurry seconds)
- motion = mean absolute difference between frames, on the subject area (find the action peaks)
- exposure = mean luma (reject too dark or blown out)
- shake = big global frame shift with no subject motion
- Audio peaks (laughs, shouts, impacts) with
astatsorebur128. They often mark the best moment.
Step 3 — Score quality first
Before choosing anything, score every candidate moment from 1 to 5 on each point and write the scores down:
- Subject: the person is clearly visible and big enough to read. A silhouette against the sun, a rider hidden inside a snow cloud or a tiny figure scores 1–2.
- Light: front or side light, real colours. Backlight, blown-out sky or deep shadow on the subject scores 1–2.
- Sharpness: Laplacian variance of the subject area, compared with the rest of the same video.
- Action: how strong the peak is. A jump with air or a big drop beats a close carve with spray toward the camera, which beats a fast carve, which beats plain cruising. Measure subject motion, not camera shake.
- Camera: steady, normal lens look, level horizon, camera moving with the subject. Fisheye spins, a warped or tilted horizon, the filmer's shadow or a flare over the subject scores 1–2.
Only moments with no score under 3 and an average of 4 or more can go into the storyboard. If there are not enough of them, remove slots and say so plainly. Never pick a weaker moment because it is "different": variety is a filter applied after quality, never the goal. Then look at the top candidates yourself in full-size frames and ask: would this make someone stop scrolling? If not, it does not go in.
Step 3a — Learn the user's taste
Keep two lists for the project: liked (with what the user said) and rejected (with the reason). Turn them into rules and apply them to every new candidate. Never offer a rejected moment again, not even as a backup. Example from a real project: liked = speed, close carves, rider clearly visible, long clean shots that "continue a bit more"; rejected = face close to the camera, fisheye spin, rider hidden by snow spray, backlit silhouette, static poses.
Step 3b — Pick the moments
A good moment has:
- action at its peak (jump, trick, turn, spray of snow, a fall, a high five)
- real faces and smiles, a group reacting
- a "wow" view (landscape, lights, sunset)
- clear subject, sharp, good light
Reject:
- blurry, shaky, dark frames; the filmer's shadow as the main subject; long cruising with nothing happening; the camera pointing at the ground; a moment repeated by a better one
- a camera watermark in the frame when another take without it exists (crop it out only if the crop still frames the subject well)
- any moment the user already rejected in this project (see Step 3a)
Each cut: 1.2–3 s. It starts just before the action and ends right after the peak. Never cut in the middle of a movement.
Photos: pick the sharpest and most alive ones. Each photo stays 1–2 s. Keep it still, or use a very slow push (max 4% zoom). No fast Ken Burns. If the person is small in the frame, crop a little tighter so the action reads.
Step 3c — No near-duplicates
- Two cuts from the same take must be at least 10 s apart. A moment 2 s after another one is the same moment.
- Group the footage by look (same rider, same camera angle, same light). Use each look at most twice, never in two slots side by side.
- Measure it: for every pair of chosen video cuts, compare colour histograms and a small grayscale layout. Replace any pair that scores close to pairs you know are duplicates, but only with a moment that also passes Step 3.
- If the footage is one long take from one angle, say so plainly and ask for more clips instead of filling slots with look-alikes.
- Camera watermarks (Insta360, GoPro): crop about 1.2x from the top on every cut, as long as the subject stays framed.
Step 4 — Build the story
Order by feeling, not by file order:
- HOOK (0–2 s): the single strongest action moment.
- ARRIVAL: group / place / the view.
- ACTION MONTAGE: alternate video cuts and action photos. Raise the pace (shorter cuts) toward the middle. Similar actions can sit together as a block (for example a video jump right before jump photos).
- BREATHE: chairlift, food, drinks, night, family together.
- END: one calm, beautiful shot (or the biggest group photo), held 2–3 s with a fade out.
Make 2 versions of the cut list:
- A: short and fast (15–20 s)
- B: full (25–35 s) For each slot, keep 1 backup moment.
Step 5 — Storyboard (approval step)
Build one HTML page and share it with the user:
- One card per slot, in order: slot number, role (hook / arrival / action / breathe / end), source file name, in–out timecode, duration.
- For a video cut: 3 stills (start, peak, end) and a small looping preview clip (480 px wide, no sound, under 1 MB), cropped as it will appear.
- For a photo: the photo, cropped exactly as it will appear in 9:16.
- On each video card: its quality score, and why it beat the other candidates.
- Under each card: the backup option as a small thumbnail. Backups must pass the same quality bar. A slot the user already chose shows "chosen by you".
- On top: version A and version B side by side, total duration of each. Once the user picks one, show only that one.
- A "repetition check" section: each video cut with its source and timecode, and the highest similarity between any two cuts.
- At the bottom: "Rejected" strip with the moments thrown out and a few words on why, including everything the user rejected.
Then ask the user: which version, which slots to swap, anything to cut or add. Wait for the answer. After each round of changes, update the same page.
Step 6 — Render (only after approval)
- Render each cut as its own file at 1080x1920, 30 fps, same encoder settings (
-c:v libx264 -crf 18 -preset veryfast -pix_fmt yuv420p). Write to a temp .mp4 name and rename on success. - Vertical crop from horizontal video: follow the subject, do not center blindly.
- Light, natural grade on everything so photos and videos match (slight contrast and saturation, no heavy filters).
- Hard cuts on action. Fade in only on the first cut, fade out only on the last.
- Join with the concat demuxer and
-c copy. Add the silent audio track with-c:v copy. - Before sending: pull 6 full-size frames from the busiest moments and look at them. Check: no text, no watermark where avoidable, no black bars, no stretched image, correct rotation.
- Send the file to the user with one line of context.
Changes after delivery
Only re-render the slots that change, then concat again.