This commit is contained in:
2026-03-27 00:01:54 -03:00
parent 65814b5b9e
commit df6bcb01e8
14 changed files with 1246 additions and 203 deletions

View File

@@ -78,3 +78,34 @@ def load_frames(manifest: dict[int, str], frame_metadata: list[dict]) -> list[Fr
frames.sort(key=lambda f: f.sequence)
return frames
def load_frames_b64(manifest: dict[int, str], frame_metadata: list[dict]) -> list[dict]:
"""
Load frame images from S3 as base64 JPEG — lightweight, no numpy.
Returns list of dicts: {seq, timestamp, jpeg_b64}
"""
import base64
from core.storage.s3 import download_to_temp
meta_map = {m["sequence"]: m for m in frame_metadata}
frames = []
for seq, key in manifest.items():
tmp_path = download_to_temp(BUCKET, key)
try:
with open(tmp_path, "rb") as f:
jpeg_bytes = f.read()
finally:
os.unlink(tmp_path)
meta = meta_map.get(seq, {})
frames.append({
"seq": seq,
"timestamp": meta.get("timestamp", 0.0),
"jpeg_b64": base64.b64encode(jpeg_bytes).decode(),
})
frames.sort(key=lambda f: f["seq"])
return frames