Skip to content

AVIF/WEBP/ResolutionLadder - #16329

Open
CommanderTurtle wants to merge 44 commits into
omacom:quattrofrom
CommanderTurtle:feat/transcode-avif-webp
Open

CommanderTurtle wants to merge 44 commits into
omacom:quattrofrom
CommanderTurtle:feat/transcode-avif-webp

Conversation

@CommanderTurtle

@CommanderTurtle CommanderTurtle commented Oct 22, 2026 •

Copy link
Copy Markdown

I made a post under discussions/16093 - and thought I'd be the one to implement it!

This patch adds a latent resolution ladder (based on compatible-long-edge) & WebP+AVIF support (two also highly efficient image codecs). Jpeg, show the others some love!

omarchy-transcode-webpavif.patch - Updated 2026-11-22 - 11:34 EST

Preview Diff


This is solely a bin/omarchy-transcode change. To test this change, follow the instructions below for your English installed bin.

Local variant runs under slightly different system context. System patch (applies to an English user's bin without any i18n frills):

omarchy-transcode-webpavif-literal.patch

reset.sh

apply.sh

sudo bash apply.sh

apply.sh pulls the packaged copies of the files the patch names out of pacman's cache, patches those, checks the result really is the new script, and only then writes them, so there is nothing to inspect by hand:

patched: /usr/bin/omarchy-transcode (jpg, png, webp, avif)
patched: /usr/share/omarchy/bin/omarchy-transcode (jpg, png, webp, avif)
applied omarchy-transcode-webpavif-literal.patch over omarchy 4.5.0-3 / omarchy-settings 4.5.0-3 (patch built from 73a8e68cd))
click to expand - cursed local linters/helpers

Run apply.sh as many times as you like, from any directory: it always starts from the packaged copies, so re-applying after an upstream update, after a half-finished manual attempt, or on top of its own output is the same one command. It names the patch that sits beside it, and lists the two variants if you kept both in the folder. A bin you broke yourself gets repaired rather than refused, and a .rej an earlier manual attempt left behind is cleaned up on the way. If the patch does not fit the release you have installed it says which release it was built for and which one you have, and your bin stays exactly as pacman shipped it. To take it back off: sudo bash reset.sh.

If you would rather run the two steps yourself, patch -p1 -d / writes one .rej per file that refused, and the English patch names the two bin copies and no catalog, so the reject check is two files:

sudo bash reset.sh && sudo patch -p1 -d / < omarchy-transcode-webpavif-literal.patch

for f in /usr/bin/omarchy-transcode /usr/share/omarchy/bin/omarchy-transcode; do
  [[ -e "$f.rej" ]] && echo "HUNK FAILED — inspect $f.rej" || echo "clean: $f"
done

# The copy the desktop router execs is the /usr/share/omarchy/bin one, so name it;
# PATH is shadowed by any checkout of this repository.
/usr/share/omarchy/bin/omarchy-transcode --help | grep 'Pictures:'

After a pacman -Syu moves omarchy / omarchy-settings, rebuild the patch against the new release in this folder before applying it:

./gen-patch.sh && sudo bash apply.sh omarchy-transcode-webpavif-literal.patch

Gen .patch from the right checkout:

gen-patch.sh

Gen non i18n from the i18n script, for local testing (eng.):

gen-config-patches.sh

bracket lint.py:

bracket-lint.py

Extras for local testing:


screenshot-2026-10-22_13-53-11

@greptile-apps

greptile-apps Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The latest changes appear safe to merge and address the missing GIF regression coverage.

Summary

This PR adds WebP and AVIF output, long-edge resolution choices, and hardware encoding choices. The latest change adds regression tests for transparent WebM and animated AVIF exports to GIF.

  • Transcode offers separate choices for format, size, and engine.
  • Picture exports add WebP and AVIF with quality choices.
  • Video exports add WebM, AVIF, and optional hardware encoding.

Reviews (22) · Last reviewed commit: "test: cover transparent WebM and AVIF gi..." · Reviewed by Greptile

Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
@omarchybot omarchybot added the enhancement New feature or request label Oct 22, 2026
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved

@chessing234 chessing234 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin/omarchy-transcode now takes the third positional as quality, so omarchy transcode demo.mov mp4 720p and photo.jpg jpg medium keep the native size and ignore the old resolution. keep resolution in the third slot, or accept those old forms before the new quality argument.

Comment thread bin/omarchy-transcode Resolved
Probe only the first frame for picture dimensions — a multi-frame
identify concatenates per-frame dims and breaks `read` — and count
frames so animated inputs are limited to animated-capable outputs
(gif/webp/avif). Accept an old-form resolution passed in slot 3 when
it is not a known quality.
Comment thread bin/omarchy-transcode Resolved
@CommanderTurtle

Copy link
Copy Markdown
Author

bin/omarchy-transcode now takes the third positional as quality, so omarchy transcode demo.mov mp4 720p and photo.jpg jpg medium keep the native size and ignore the old resolution. keep resolution in the third slot, or accept those old forms before the new quality argument.

Thanks, appreciated note @chessing234 - Backwards compatibility could do a simple check for this.

Accepted the old forms in 1afcc7677. In main(), a third positional that isn't a known quality (high/medium/low) is treated as a resolution and quality is left empty. So omarchy transcode demo.mov mp4 720p still resolves to 720p, while photo.jpg jpg medium takes the new path (quality=medium, native size). Old-form resolution and new-form quality are disambiguated by the known-quality check, so neither regresses.

The animated-input guard rejected on the format inferred from the
filename, before the codec menu could run, so a no-argument animated
input was blocked from picking webp/avif. Validate the final chosen
format instead, once the menus have settled it.
Comment thread bin/omarchy-transcode Resolved
The webp and avif encoder paths funnel the input through a single-frame
.png temp, so a multi-frame picture (animated GIF, APNG) fails at the
ffmpeg step before the encoder runs. For animated inputs, encode directly
with magick (which the jpg/png paths already use), preserving frames and
timing. Stills keep the cwebp/avifenc path.
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
- GIFs route by output format: picture formats (jpg/png/webp) take the
  picture path, so gif->webp and still-GIF->jpg/png work again; avif
  and the other video formats keep the video path.
- Animated AVIFs decode to a frame sequence once, before encoder
  selection, so every output (avif/webm/mp4/gif) keeps all frames.
  Per-frame delays ride a concat list instead of a rounded average
  fps; the decode tmpdir cleans up on every exit path.
- -fps_mode passthrough on every video encode: the avif/webm muxers
  pick high-rate timebases and default CFR resampling duplicated
  frames to fill them (a 10 fps GIF became 20 frames of dupes).
- CPU avif/webm encodes keep the input's alpha (yuva444p/yuva420p);
  the GPU GIF path uploads software-decoded frames before scale_cuda.
- The gpu engine is CUDA (av1_nvenc/scale_cuda); only offer it in the
  menu where omarchy-hw-nvidia sees an NVIDIA GPU, defaulting to cpu
  on AMD and Intel.
- Quote the "gpu" literal in [[ ]] comparisons.
- gpu engine auto-detects the vendor (NVIDIA/AMD/Intel via PCI class
  0x03) and selects the matching hardware AV1 encoder (av1_nvenc /
  av1_amf / av1_qsv), probed with a real encode; falls back to cpu
  when the encoder is unusable on this silicon. Menu offers gpu only
  where a usable hardware encoder is compiled in.
- Hardware AV1 encodes scale small inputs up to the nvenc 256x144
  floor (proportional, no-op above it) so small sources don't error.
- The GPU GIF pipeline uses hwupload_cuda (self-created device) after
  a software yuv420p convert; -hwaccel cuda on a software-decoded GIF
  never yields a device reference for hwupload.
- Alpha-carrying AVIF output is encoded by magick (libheif) because
  the ffmpeg avif muxer drops the alpha auxiliary; per-frame delays
  survive the coalesce. Non-alpha AVIF stays on the libaom path.
- input_has_alpha: AVIF alpha is a separate gray stream the demuxer
  exposes; GIFs are judged by palette alpha mode (IM7 reports Blend,
  not True) since the gif decoder's bgra would flag every GIF.
- Quoted the gpu literal in [[ ]] and made -fps_mode passthrough
  unconditional (avif/webm muxers duplicate frames to fill high-rate
  timebases).
The engine is no longer a menu question. It is chosen automatically:
hardware AV1 where the vendor's encoder is compiled in (NVIDIA/AMD/Intel),
cpu otherwise; mp4 and pictures never use it. An explicit positional
still overrides. The gif->avif alpha rule keeps that path on cpu.

gpu_available no longer SIGPIPES: grep -q exits on first match, which
under pipefail scored the pipeline 141 and made the check always fail
whenever the encoder existed - so auto would have fallen back to cpu on
every machine that has the encoder. A here-string fixes it. The avif
alpha probe had the same shape and is fixed the same way.

ffmpeg exits 0 when it declines to overwrite an existing output, so a
re-transcode to the same name silently kept the stale file, was copied
to the clipboard, and announced success. All output encodes now pass
-y, matching the picture path's silent overwrite.

The orphaned transcode.engine i18n key is removed.
The gpu/cpu ask returns for avif and webm - the formats where the
hardware encoder changes the result - and only when the vendor's
encoder passes the live probe, so a gpu pick is always honored. Probe
fails (e.g. VRAM pressure) -> silent cpu, no ask. gif keeps the
auto CUDA-scale detection; mp4 and pictures stay cpu. An explicit
positional still overrides.

main() now runs the probe for the ask and transcode_video reuses the
result instead of probing a second time.

The transcode.engine i18n key is restored with the ask.
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
Comment thread bin/omarchy-transcode Resolved
libheif's per-frame delay is a 1024cs placeholder for ffmpeg-written
avif, which stretched playback ~100x. Carry the per-frame delays only
when their sum reconciles with the container duration (within 25%),
otherwise distribute the container total uniformly; both cases keep
the input framerate.
Comment thread bin/omarchy-transcode Resolved
@CommanderTurtle

Copy link
Copy Markdown
Author

All three regression checks are implemented in local commit 83e44fe1:

  • Ordered AVIF/WebM GPU gates, live driver/memory probes, AMD/Intel paths, and missing-package install hints.
  • Alpha-preserving static AVIF/WebP resizing, verified across all four format pairings.
  • Descending long-edge ladders for both orientations; legacy height aliases remain CLI-only.

High encoder settings, NVIDIA quality flags, and AVIF timing remain unchanged.

The single test bench passes all 14 checks. Hardware routing was fixture-tested, and verified on live Linux GPU.

Comment thread bin/omarchy-transcode Resolved
Includes the JPG/PNG auto-orient fix proposed by AksharP5 in omacom#16554, extended to static WebP/AVIF intermediates. Keep source files and encoder quality settings unchanged; cover rotated, mirrored, normal and untagged inputs in the existing bench.
@CommanderTurtle

CommanderTurtle commented Oct 25, 2026 •

Copy link
Copy Markdown
Author

Added #16554 in the same manner for EXIF metadata edge-cases. So this now fixes #16553 - included even in the new formats.

Kept the scope narrow. Two files, test/shell.d/transcode-test.sh is now a 16-rung check. All pass, including rotation, mirroring, metadata removal, and all previous fixtures. This new regression fails before the fix.

@CommanderTurtle

Copy link
Copy Markdown
Author
screenrecording-2026-10-25_15-18-33-1920.mp4

Full final behavior. No frills, showcase of what you can expect!

File manager is my omafile fork

Cool read for newbies to avif: https://github.com/george-hawkins/video-in-github-markdown/blob/master/README.md

Comment thread bin/omarchy-transcode Resolved
Comment thread test/shell.d/transcode-test.sh Resolved
The gif commands opened the file directly while every other format in that switch reads the decoded sequence from src_in, so a transparent WebM or animated AVIF lost its alpha plane to the native decoder and palettegen had no transparency left to reserve. A transparent two-frame WebM's gif goes from an extracted-alpha mean of 1.0 (opaque) to 0.77.
Animated WebP and AVIF encode through ImageMagick's own libwebp and libheif delegates, which imagemagick already pulls in, so refusing the format up front blocked conversions on a stock install that never call cwebp or avifenc. The refusal now sits in the still route that shells out to the CLI.
libwebp-utils and libavif are in neither default package list, and CI runs the suite on a fresh install image, so the orientation loop failed on its first WebP export, long before require_command reached it. Gate each picture format on its encoder and skip the checks that need one, the way a missing compositor is skipped; the file now passes with and without both packages installed.
Comment thread bin/omarchy-transcode Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants