Repository navigation
Commit bf745ac
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
PiperOrigin-RevId: 9828889711 parent 3139855 commit bf745ac
6 files changed
Lines changed: 1069 additions & 25 deletions
File tree
- src/google/adk/live
- tests/unittests/live
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
155 | 155 | | |
156 | 156 | | |
157 | 157 | | |
158 | | - | |
159 | | - | |
160 | | - | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
167 | 161 | | |
168 | 162 | | |
169 | 163 | | |
| |||
316 | 310 | | |
317 | 311 | | |
318 | 312 | | |
319 | | - | |
320 | 313 | | |
321 | 314 | | |
322 | 315 | | |
323 | 316 | | |
324 | 317 | | |
325 | 318 | | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
337 | 322 | | |
338 | 323 | | |
339 | 324 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
122 | 151 | | |
123 | 152 | | |
124 | 153 | | |
| |||
0 commit comments