Repository navigation
Add support for PNG - #4
Conversation
|
This is a starting point. I'll be adding code to this ... |
… it. Had to unpack it
There was a problem hiding this comment.
Pull request overview
This PR generalizes frame capture and caching from JPEG-only to support both JPEG and PNG output, and exposes PNG capture via new API endpoints. It also updates the build/tooling to sbt 2.0.0 and refreshes several dependency/plugin versions.
Changes:
- Introduce
ImageTypeand update capture/cache types to work with multiple image formats (JPEG/PNG). - Extend ffmpeg invocation to emit PNGs when the target path ends in
.png, and add new/capture/pngendpoint. - Update tests and build/tooling (sbt 2, Scala 3.8.4, refreshed plugins/dependencies, workflow fixes).
Reviewed changes
Copilot reviewed 36 out of 38 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/test/scala/org/mbari/beholder/TestUtil.scala | Ensures test video resource is usable even when packed into a JAR (sbt 2), by extracting to a temp file. |
| src/test/scala/org/mbari/beholder/SanitySuite.scala | Removes unused JUnit imports as tests run under MUnit. |
| src/test/scala/org/mbari/beholder/JpegCacheSuite.scala | Removes legacy JPEG-only cache tests (replaced by multi-type cache suite). |
| src/test/scala/org/mbari/beholder/JpegCache2Suite.scala | Removes legacy cache v2 tests (replaced by multi-type cache suite). |
| src/test/scala/org/mbari/beholder/ImageCaptureSuite.scala | Renames and updates capture test to use ImageCapture + ImageCacheImpl. |
| src/test/scala/org/mbari/beholder/ImageCacheImplSuite.scala | Adds test coverage for JPEG, PNG, and mixed-type cache behavior. |
| src/test/scala/org/mbari/beholder/etc/jdk/PathUtilSuite.scala | Adds useExtension test and retains URL/path tests. |
| src/test/scala/org/mbari/beholder/etc/ffmpeg/FfmpegUtilSuite.scala | Adds png frame-capture test alongside jpg. |
| src/test/scala/org/mbari/beholder/CachedImageSuite.scala | Updates tests to validate .jpg and .png path generation. |
| src/test/scala/org/mbari/beholder/api/CaptureEndpointsSuite.scala | Updates endpoint tests to use new cache/capture types. |
| src/main/scala/org/mbari/beholder/util/VectorUtil.scala | Minor formatting/line numbering change only. |
| src/main/scala/org/mbari/beholder/Main.scala | Switches runtime wiring to ImageCacheImpl + ImageCapture; reorganizes imports. |
| src/main/scala/org/mbari/beholder/JpegCapture.scala | Removes JPEG-only capture implementation (replaced by ImageCapture). |
| src/main/scala/org/mbari/beholder/JpegCache.scala | Removes legacy JPEG-only cache implementation. |
| src/main/scala/org/mbari/beholder/ImageType.scala | Adds image type enum (JPEG/PNG) with extensions and media types. |
| src/main/scala/org/mbari/beholder/ImageCapture.scala | Adds image-type-aware capture implementation. |
| src/main/scala/org/mbari/beholder/ImageCacheImpl.scala | Updates cache implementation to key by (elapsedMs, imageType) and scan both formats. |
| src/main/scala/org/mbari/beholder/ImageCache.scala | Updates cache trait APIs to operate on CachedImage and include imageType in lookups/removals. |
| src/main/scala/org/mbari/beholder/etc/zio/ZioUtil.scala | Import ordering only. |
| src/main/scala/org/mbari/beholder/etc/xml/Converters.scala | Import grouping/formatting only. |
| src/main/scala/org/mbari/beholder/etc/jdk/PathUtil.scala | Adds useExtension and isPng. |
| src/main/scala/org/mbari/beholder/etc/ffmpeg/FfmpegUtil.scala | Adds command builder + execution wrapper and supports PNG output based on target extension. |
| src/main/scala/org/mbari/beholder/etc/ffmpeg/DurationString.scala | Import ordering only. |
| src/main/scala/org/mbari/beholder/etc/circe/CirceCodecs.scala | Removes an unused import. |
| src/main/scala/org/mbari/beholder/CachedImage.scala | Renames Jpeg to CachedImage and supports parsing/paths for both jpg/png. |
| src/main/scala/org/mbari/beholder/AppConfig.scala | Formatting only. |
| src/main/scala/org/mbari/beholder/api/SwaggerEndpoints.scala | Import ordering only (but Swagger generation should include new endpoints). |
| src/main/scala/org/mbari/beholder/api/HealthStatus.scala | Formatting only. |
| src/main/scala/org/mbari/beholder/api/HealthEndpoints.scala | Import ordering only. |
| src/main/scala/org/mbari/beholder/api/Endpoints.scala | Import ordering only. |
| src/main/scala/org/mbari/beholder/api/CaptureRequest.scala | Removes unused imports. |
| src/main/scala/org/mbari/beholder/api/CaptureEndpoints.scala | Adds /capture/jpg + /capture/png endpoints and shared logic with ImageCapture. |
| project/plugins.sbt | Updates/modernizes sbt plugins and adds scalafix. |
| project/Dependencies.scala | Bumps library versions and updates Scala 3 style. |
| project/build.properties | Upgrades to sbt 2.0.0. |
| build.sbt | Updates Scala version, enables semanticdb/scalafix support, and tweaks test options/build settings. |
| .github/workflows/test.yml | Fixes Java version to 25 for CI. |
| .github/workflows/docs.yml | Updates docs artifact path for Scala 3.8.4. |
Comments suppressed due to low confidence (3)
src/main/scala/org/mbari/beholder/ImageCacheImpl.scala:71
evictionOrderingdoesn't includeimageType(orpath) as a tie-breaker. If a JPEG and PNG share the samecreatedtimestamp (common on restart when filesystem timestamps have coarse resolution) and the same(videoUri, elapsedTime), the comparator returns 0 andConcurrentSkipListSetwill drop one entry, breaking mixed-type caching/eviction.
src/main/scala/org/mbari/beholder/ImageCacheImpl.scala:111putstores the stamped value (with updatedcreated) but returns the originaljpegargument. This makes the method contract/documentation misleading and prevents callers from using the returned value as the canonical cache entry (e.g., for eviction ordering/debugging).
src/main/scala/org/mbari/beholder/ImageCacheImpl.scala:145- The eviction log message still says "jpegs", but the cache now stores multiple image types (e.g., PNG). This will be misleading when debugging cache behavior.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…ndpoints to swagger
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 40 out of 42 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (3)
src/main/scala/org/mbari/beholder/ImageCacheImpl.scala:69
evictionOrderingdoes not includeimageTypeas a tie-breaker. With the new mixed-type cache key ((elapsedMs, ImageType)), two entries with the samecreated,videoUri, andelapsedTimebut differentimageTypecan compare as equal (0), causingConcurrentSkipListSetto drop one entry and potentially break eviction/index consistency.
src/main/scala/org/mbari/beholder/ImageCacheImpl.scala:112putstampscreated = Instant.now()intostampedand stores that in the index/eviction queue, but returns the originaljpegvalue. This makes the returned object inconsistent with what was actually stored (and with the scaladoc saying the stored image has updated creation time).
src/main/scala/org/mbari/beholder/ImageCacheImpl.scala:33- The class scaladoc still describes this as a "JPEG frame cache" indexed by (videoUri, elapsedTime), but the implementation now supports multiple image types and indexes by (videoUri, elapsedTime, imageType). Updating the doc avoids misleading API consumers.
|
Issue with i2map video when new beholder is trying to grab frames in gridview, see screenshot, this worked last week for i2map in gridivew with old version of beholder (Kevin message from email: It seems Beholder is getting 500 errors when trying to grab frames from i2MAP footage). For more information check: https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500 |

Requested by @kwalz in mbari-org/dfg-tool#3