Skip to content

feat(live): add ZIP_STORED media frame pack and unpack helpers - #7152

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

@copybara-service copybara-service Bot commented Sep 17, 2026

Copy link
Copy Markdown

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

Realtime live sessions produce streams of image/* and video/* frames alongside
audio/* chunks. Persisting each frame as a separate artifact creates O(F)
storage operations per turn, while adding a batch method to BaseArtifactService
expands the abstract storage interface across every backend.

This change adds google.adk.live._media_frames with standalone helpers to
pack and unpack sequences of MediaFrame entries as a single uncompressed
(zipfile.ZIP_STORED) .zip archive (application/zip) that can be saved and
loaded through the existing BaseArtifactService.save_artifact() /
load_artifact() methods:

  • MediaFrame: Pydantic model pairing a types.Blob frame payload with its
    capture timestamp.
  • pack_media_frames(): validates non-empty frames and non-decreasing capture
    timestamps, writes frames/frame_NNNN.<ext> members and a metadata.json
    timing manifest into an uncompressed (zipfile.ZIP_STORED) ZIP archive, and
    returns (archive_bytes, manifest).
  • unpack_media_frames(): full round-trip inverse that restores (list[MediaFrame], manifest)
    from archive bytes.
  • read_manifest(), extract_frame(), extract_preview_frame(), and
    summarize_manifest(): O(1) central-directory helpers to inspect the
    manifest or read individual keyframes (such as frames/frame_0000.jpeg)
    without inflating the full archive or storing a separate preview artifact.

Testing:

  • pytest tests/unittests/live/test_media_frames.py: 68 passed.

@copybara-service
copybara-service Bot force-pushed the copybara/982888971 branch 6 times, most recently from 759ecb3 to 57755cc Compare September 18, 2026 19:17
@copybara-service copybara-service Bot changed the title feat(artifacts): add save_media_frames() for batched media persistence feat(live): add ZIP_STORED media frame pack and unpack helpers Sep 18, 2026
@copybara-service
copybara-service Bot force-pushed the copybara/982888971 branch 5 times, most recently from 8b99875 to 04e6b33 Compare September 19, 2026 02:33
Realtime live sessions produce streams of `image/*` and `video/*` frames alongside
`audio/*` chunks. Persisting each frame as a separate artifact creates `O(F)`
storage operations per turn, while adding a batch method to `BaseArtifactService`
expands the abstract storage interface across every backend.

This change adds `google.adk.live._media_frames` with standalone helpers to
pack and unpack sequences of `MediaFrame` entries as a single uncompressed
(`zipfile.ZIP_STORED`) `.zip` archive (`application/zip`) that can be saved and
loaded through the existing `BaseArtifactService.save_artifact()` /
`load_artifact()` methods:

- `MediaFrame`: Pydantic model pairing a `types.Blob` frame payload with its
  capture timestamp.
- `pack_media_frames()`: validates non-empty frames and non-decreasing capture
  timestamps, writes `frames/frame_NNNN.<ext>` members and a `metadata.json`
  timing manifest into an uncompressed (`zipfile.ZIP_STORED`) ZIP archive, and
  returns `(archive_bytes, manifest)`.
- `unpack_media_frames()`: full round-trip inverse that restores `(list[MediaFrame], manifest)`
  from archive bytes.
- `read_manifest()`, `extract_frame()`, `extract_preview_frame()`, and
  `summarize_manifest()`: `O(1)` central-directory helpers to inspect the
  manifest or read individual keyframes (such as `frames/frame_0000.jpeg`)
  without inflating the full archive or storing a separate preview artifact.

Testing:
- `pytest tests/unittests/live/test_media_frames.py`: 68 passed.
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