Skip to content

feat: AVIF, HEIC, and APNG through Describe, and remux_video passes - #15

Merged
rosylilly merged 5 commits into
mainfrom
feat/describe-extended-formats
Nov 25, 2026
Merged

rosylilly merged 5 commits into
mainfrom
feat/describe-extended-formats

Conversation

@rosylilly

Copy link
Copy Markdown
Member

Summary

This follows mycroblog/my's main: #3499 (Describe and the formats AVIF, HEIC, and APNG) and #3501 (the media_video contract MP4, issue #3494). Neither is in a tag yet, so this pins a commit of main, f55bdcb.

  • Pin: buf.gen.yaml takes ref: (a tag or a commit). CI builds my from that ref with a fetch, which takes both, and caches the build by the ref.
  • internal/media:
    • The service answers Describe with ImageProcessor.InputFormats(). It takes no slot, so a busy plugin still answers. A plugin without images answers unimplemented, which the server reads as the built-in formats only.
    • SniffImage tells AVIF and HEIC apart by their ftyp brands, and SniffAV no longer takes them for an MP4.
    • SniffImageFile tells an APNG apart by an acTL before its first IDAT. The two plugins now share it and SniffAVFile instead of keeping a copy each.
  • my-media-imagemagick:
    • AVIF and HEIC: decoded through libheif, with the dav1d and libde265 decoders. The policy allows those two coders for reading only.
    • Declaration: at start, the plugin decodes a small sample of each format and declares only those its ImageMagick decodes, plus APNG. It logs accepts JPEG, PNG, GIF, WebP, and AVIF, HEIC, APNG.
    • APNG: ImageMagick reads it only through FFmpeg as a delegate, and the policy keeps that off. The plugin reads APNG itself instead (apng.go):
      • It reads the chunks and checks the limits on frames and pixels before decoding a pixel.
      • It composes each frame on the canvas with the dispose and blend operations of APNG 1.0.
      • It writes each frame to a PNG of its own that keeps the file's color space chunks (iCCP and the others), and passes the frames to ImageMagick as one animation.
    • README: the format table and the server version needed (one with #3499), the decoders to install outside Docker, and the policy.
  • my-media-ffmpeg: drops the known failure media_video/remux_video, since #3494 is fixed. The README now says #3493 left video and audio out.

Verified

  • my plugin test built from f55bdcb, over a unix socket, gRPC on a unix socket, and plain TCP:
    • my-media-imagemagick: every case passes, including describe.
    • my-media-ffmpeg: every case passes, including remux_video.
  • Describe on the running containers:
    • imagemagick answers {"inputFormats":["FORMAT_AVIF","FORMAT_HEIC","FORMAT_APNG"]}.
    • ffmpeg answers unimplemented.
  • The test stage (MY_PLUGIN_REQUIRE_TOOLS=1) runs these new tests:
    • APNG composition (each dispose and blend operation, a default image that is not a frame, the iCCP kept), refusal of broken APNGs (7 cases), and the limit on frames
    • AVIF and HEIC from the samples
    • a HEIC stored with EXIF orientation 6 and its irot, which comes out turned once, not twice
    • an undeclared format refused
  • scripts/lint.sh passes.

Notes

  • Because ci.yml changed, this PR runs every test. The internal/server tests are flaky under parallel load (unrelated to this PR); I'll fix that in a separate PR.
  • When rc.12 or a later tag comes out, change ref back to that tag.
  • An AVIF or HEIC image sequence (animated AVIF, a burst) becomes a still of its primary image.

🤖 Generated with Claude Code

rosylilly and others added 5 commits November 25, 2026 11:27
mycroblog/my#3499 adds Describe to MediaService, through which a plugin of images
declares AVIF, HEIC, and APNG, and #3501 fixes the MP4 of the media_video contract.
Neither is released yet, so buf.gen.yaml pins a commit of main (ref), and CI builds
`my plugin test` from that ref: a fetch takes a tag or a commit alike.

internal/media answers Describe with ImageProcessor.InputFormats, without taking a
slot, so that a busy plugin still answers it; without images it is unimplemented,
which the server reads as the built-in formats only. SniffImage tells AVIF and
HEIC by the brands of the ftyp box, SniffAV no longer takes them for an MP4, and
SniffImageFile tells an APNG by an acTL before its first IDAT. The plugins share
SniffImageFile and SniffAVFile instead of a copy each.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AVIF and HEIC go through libheif (dav1d and libde265, decoders only), which the
policy allows for reading only. At start the plugin decodes a small image of
each and declares the formats its ImageMagick decodes, and APNG.

ImageMagick reads an APNG only through FFmpeg as a delegate, which the policy
keeps off. The plugin reads it itself: apngInspect reads the frames from the
chunks for the limits before a pixel is decoded, and apngFrames composes each
frame on the canvas (dispose and blend of APNG 1.0) into a PNG of its own, with
the color space chunks of the file, which ImageMagick reads as an animation.

A HEIC stored with the transformation of EXIF orientation 6 is turned once: the
test pins that libheif turns it and the EXIF does not turn it again.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@rosylilly
rosylilly merged commit 4aec651 into main Nov 25, 2026
9 checks passed
@rosylilly
rosylilly deleted the feat/describe-extended-formats branch November 25, 2026 02:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant