Skip to guide

Gemini API video slicing example

Find a missed parcel scan in a 32-second video and use the event log to select the four seconds that show it.

Watch the four-second clip

Parcel 03 passes the scanner at 00:19 with no scan confirmation. This silent local replay covers 00:18 to 00:22 of the original video.

Find the time range locally

The ZIP includes the full video, the four-second clip, the event log, the Python lookup and a README. Extract it and run this command in the extracted folder. The lookup uses Python 3 and needs no API key or network access.

python3 read_event.py event-log.json 03

The lookup reads the event at second 19 in line-07.mp4 and returns scan_confirmed: false, start_offset: "18s" and end_offset: "22s".

Pass the same range to Gemini

Live API untested. This example verifies the local lookup and replay. The JSON below illustrates the request shape from Google’s documentation.

Upload the full line-07.mp4 to the Gemini Files API. Replace FILES_API_URI with the URI from that upload. The static processing options ask Gemini to load the selected interval from the full file.

{
  "model": "gemini-4-hydrogen",
  "input": [
    {
      "type": "video",
      "uri": "FILES_API_URI",
      "mime_type": "video/mp4",
      "processing": {
        "type": "static",
        "start_offset": "18s",
        "end_offset": "22s"
      }
    },
    {
      "type": "text",
      "text": "Which parcel passes without a scan confirmation?"
    }
  ]
}

See Google’s video clipping guide for the complete Interactions API call and Google’s file slicing announcement for the supported media types.