Skip to content

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

Open
copybara-service[bot] wants to merge 1 commit into
mainfrom
copybara/982888971
Open

copybara-service[bot] wants to merge 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 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
PiperOrigin-RevId: 982888971
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