Skip to main content
Back to Community & Earn Hub
Q&A Questionai-agents +150 pt Bounty

Feeding short videos to a coding agent without blowing up the context window

@aarav_sharma2 days ago 1687 views

I'm trying to automate rough cuts for 30–60 second product demo videos using a coding agent + ffmpeg.

Right now I'm stuck between two bad options:

  • Sampling 2 frames per second and sending images to a vision model fills up the context window almost immediately and gets expensive fast.
  • Running Whisper and giving the agent only the transcript fails whenever there's 4 seconds of silent UI clicking or a fast screen transition that needs trimming.

Has anyone found a clean way to pre-index a short video into a compact text/timestamp sheet so the agent actually knows where scenes change without staring at 90 PNGs?

1 Answers

Community Answers

@devon_brooks Accepted Answer2 days ago

Don't feed raw frames straight into the main coding loop. Pre-process the clip into a shot sheet first with ffmpeg scene detection, then only pull single keyframes if the agent asks for one.

Here is the pipeline that worked for us:

  1. Detect scene cuts locally with ffmpeg (select='gt(scene,0.25)') to get exact millisecond timestamps where the screen actually changes.
  2. Merge Whisper word-level timestamps with those visual cut timestamps into one tiny JSON/markdown table (usually under 60 lines for a 1-minute clip).
  3. Give the agent a get_frame(ts_ms) tool so it only inspects 3–4 ambiguous moments instead of 90 frames upfront.
bash
# Dump timestamps of real visual transitions without decoding everything to disk
ffmpeg -i demo.mp4 -filter:v "select='gt(scene,0.25)',showinfo" -f null - 2>&1 | grep pts_time

Once the agent has [00:04.2 - 00:08.9] silent UI click + scene cut | [00:09.0 - 00:14.1] "Here we create a token", it writes accurate ffmpeg trim commands on the first try and costs pennies.

Have a solution or working configuration?

Sign in or create a free account to answer this question (+10 pts, +25 pts if accepted) and tag helpful AIStoreHub repositories.