Skip to content

feat(live): add ZIP_STORED visual frame pack and unpack helpers - #7562

Merged
copybara-service[bot] merged 1 commit into
mainfrom
copybara/982888971
Oct 16, 2026
Merged

copybara-service[bot] merged 1 commit into
mainfrom
copybara/982888971

Conversation

@copybara-service

Copy link
Copy Markdown

feat(live): add ZIP_STORED visual frame pack and unpack helpers

Live video reaches ADK as image/* frames, alongside audio/* chunks. Saving each frame as its own artifact costs one storage operation per frame, while adding a batch method to BaseArtifactService would grow the abstract storage interface for every backend.

This change adds google.adk.live._visual_frames, which packs a frame sequence into one uncompressed (zipfile.ZIP_STORED) .zip archive that the existing save_artifact() / load_artifact() methods store as is:

  • VisualFrame: a Pydantic model pairing a frame's types.Blob with its capture timestamp.
  • pack_visual_frames(): validates the frames (non-empty data, finite and non-decreasing timestamps), writes frames/frame_NNNN.<ext> members and a metadata.json timing manifest, and returns (archive_bytes, manifest).
  • unpack_visual_frames(): the inverse; restores (list[VisualFrame], manifest) from the archive bytes.
  • summarize_manifest(): the manifest without its per-frame index, small enough for an artifact's custom_metadata.
  • VISUAL_FRAMES_ZIP_MIME_TYPE: the archive's MIME type, application/zip.

NO_UNIT_GUIDE=Internal pack/unpack helper module for live visual frames

Live video reaches ADK as `image/*` frames, alongside `audio/*` chunks. Saving each frame as its own artifact costs one storage operation per frame, while adding a batch method to `BaseArtifactService` would grow the abstract storage interface for every backend.

This change adds `google.adk.live._visual_frames`, which packs a frame sequence into one uncompressed (`zipfile.ZIP_STORED`) `.zip` archive that the existing `save_artifact()` / `load_artifact()` methods store as is:

- `VisualFrame`: a Pydantic model pairing a frame's `types.Blob` with the wall-clock time it was received; a NaN or infinite time is rejected when the frame is created.
- `pack_visual_frames()`: validates the frames (non-empty data, non-decreasing timestamps), writes `frames/frame_NNNN.<ext>` members and a versioned `metadata.json` manifest whose millisecond fields all derive from the same rounded times, and returns `(archive_bytes, artifact_metadata)`, where the metadata is the manifest without its per-frame index, small enough for an artifact's `custom_metadata`.
- `unpack_visual_frames()`: the inverse; restores `(list[VisualFrame], manifest)` from the archive bytes, with each time to the nearest millisecond. It reads only stored, unencrypted members, each listed frame once, and rejects an unknown `formatVersion`, so every failure is a `ValueError`.
- `VISUAL_FRAMES_ZIP_MIME_TYPE`: the archive's MIME type, `application/zip`.

PiperOrigin-RevId: 1001035243
@copybara-service
copybara-service Bot merged commit 17d8a5a into main Oct 16, 2026
15 of 20 checks passed
@copybara-service
copybara-service Bot deleted the copybara/982888971 branch October 16, 2026 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant