Skip to content

Ask before normalizing screen recording audio that's unusually quiet or loud - #8809

Open
ogarza wants to merge 7 commits into
omacom:quattrofrom
ogarza:prompt-for-audio-normalization-if-desktop-audio-not-loud
Open

ogarza wants to merge 7 commits into
omacom:quattrofrom
ogarza:prompt-for-audio-normalization-if-desktop-audio-not-loud

Conversation

@ogarza

@ogarza ogarza commented Aug 28, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Discussion: #9020

Screen recordings no longer always run loudnorm on stop. That was crushing quiet sounds and dynamic range.

After stop, short recordings are measured. If the audio is unusually quiet (more than 4 LU below -14 LUFS) or unusually loud (more than 3 LU above), a menu asks whether to normalize to typical broadcast levels or keep the recording as-is. Esc keeps the original. Audio already in that window is left alone.

Recordings longer than 10 minutes skip that analysis and ask immediately — measuring a long soundtrack left a dead screen after the bar indicator was already gone. The prompt is “Normalize audio to typical broadcast levels?” with Normalize (Recommended) first. Saying yes does a single loudnorm pass in the remux, same as OMARCHY_SCREENRECORD_NORMALIZE=true. Short clips that accept still get the two-pass path with the first-pass stats.

The PipeWire capture-pop mute still always runs. OMARCHY_SCREENRECORD_NORMALIZE=true always normalizes; false never asks.

screenshot-2026-08-31_02-29-04

Test plan

  • Record with desktop audio that is clearly quiet; stopping should ask “Audio may be unintentionally quiet” with Keep original / Normalize
  • Record with hot audio (well above broadcast level); stopping should ask “Audio may be unintentionally loud”
  • Esc or Keep original leaves levels alone; Normalize raises or lowers toward typical broadcast levels
  • A recording already near normal speech volume should not prompt
  • A recording longer than 10 minutes asks immediately (no analysis wait), with Normalize recommended; yes is a single loudnorm pass
  • OMARCHY_SCREENRECORD_NORMALIZE=false never asks
  • bash test/shell.d/screenrecording-test.sh

Copilot AI balanced review requested due to automatic review settings August 28, 2026 19:40

Copilot AI 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.

Pull request overview

Adds conditional audio normalization for screen recordings while preserving PipeWire pop suppression.

Changes:

  • Measures loudness and prompts only outside the -18 to -11 LUFS range.
  • Adds CLI/environment overrides and persists start-time preferences.
  • Expands tests and user documentation.

Tip

If you aren't ready for review, convert to a draft PR.
Click "Convert to draft" or run gh pr ready --undo.
Click "Ready for review" or run gh pr ready to reengage.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
bin/omarchy-capture-screenrecording Implements measurement, prompting, overrides, and optional normalization.
test/shell.d/screenrecording-test.sh Tests thresholds, preferences, filtering, and prompt outcomes.
manual/12-screenshots-recording.md Documents conditional normalization behavior.
manual/14-omarchy-cli.md Lists the new CLI flags.
default/agents/skills/omarchy/capture.md Updates agent-facing capture guidance.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

ogarza and others added 3 commits August 29, 2026 17:15
Moving the output-directory check inside start_screenrecording let
`start_screenrecording || cleanup_webcam` swallow its non-zero return:
cleanup_webcam ends in a successful `rm -f`, so a missing directory
notified the user and then exited 0. It exited 1 before this branch.

Guard the start branch of the dispatcher instead. That restores the
failing status without putting the check back in front of stopping,
which still has to finalize a recording whose directory went away.

Co-Authored-By: Codex XHigh <[email protected]>
Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Claude-Session: https://claude.ai/code/session_01UgPCZR2xnMwJELod9nfou2
@omarchybot

Copy link
Copy Markdown
Collaborator

Reviewed this by hand, with an independent second opinion from Codex XHigh. It found four defects; I verified each against the source and accepted two, rejected one, and treated one as yours to decide. Don't merge yet — one confirmed regression is now fixed on the branch, but the stop path can still be left stranded by the new prompt, and that one is a design call rather than a patch.

Pushed to the branch: a missing recording directory reported success. Moving the [[ ! -d $OUTPUT_DIR ]] check inside start_screenrecording put its return 1 behind start_screenrecording || cleanup_webcam, and cleanup_webcam ends in a successful rm -f — so the whole command exited 0. Measured on both sides: OMARCHY_SCREENRECORD_DIR=/nonexistent omarchy-capture-screenrecording exits 1 on quattro and exited 0 on this branch. The guard now sits in the start branch of the dispatcher, which restores the failing status without putting the directory check back in front of stopping — that part of the move was a genuine improvement and is now covered by a test of its own. Both new tests were proven by mutation: the first fails against the pre-fix file, the second fails against quattro.

Still open, and the reason not to merge: the prompt can strand finalization. decide_normalize blocks on omarchy-menu-select, which waits on a done-file with no timeout (bin/omarchy-menu-select:91). Menu.openExistingMenu clears selectionFile/doneFile without calling finishRequest (shell/plugins/menu/Menu.qml:838-844), so anything that opens another menu while the normalize prompt is up — pressing the menu keybind, any omarchy-menu invocation, a shell restart — releases nothing and the waiting stop process never returns. Esc and click-away are fine; cancel() does complete the request, so that path is safe. But when it does strand, the recording is left un-finalized: no first-frame trim, no PipeWire pop mute, no notification, and both state files still on disk. That mechanism predates this PR, but until now no menu-select sat inside a path that has to finish writing a file.

Related, and the reason this is worth solving rather than papering over: stop_screenrecording re-reads RECORDING_FILE after finalize_recording (bin/omarchy-capture-screenrecording:403-404). That was a sub-second window; with a prompt in the middle it is open-ended, so a stop that is answered late will build its preview and notification from whatever recording is current by then, and delete that recording's state files.

On the complexity note: the part that does not earn its keep is the start-time flag tier. persist_normalize_preference, NORMALIZE_FILE, the sidecar branch of normalize_preference, its cleanup, and about twenty lines of test exist so --normalize-audio can be passed at start and read at stop. Nothing in the shipped UI passes it — the menu entries and the keybinding don't — and OMARCHY_SCREENRECORD_NORMALIZE already covers "don't ask me this session", while the flag still works when passed to the stop invocation directly. Dropping that tier removes a file, a function, a cleanup path and a whole precedence level without changing anything a user can see. The two-pass path, by contrast, does earn it (below).

Codex also flagged that OMARCHY_SCREENRECORD_NORMALIZE in the stop process overrides an explicit --normalize-audio given at start. That's real, and the test asserting "invocation flags beat the env var" only exercises same-process precedence, so it doesn't cover it. Whether the env var should win is your call — it's defensible either way, and the docs don't currently say.

I rejected its finding about XDG_RUNTIME_DIR differing between start and stop: NORMALIZE_FILE uses exactly the ${XDG_RUNTIME_DIR:-/tmp} form that REGION_FILE on the line above it already uses, so that's the file's own convention, not something this branch introduced.

Coverage. The helper tests are good and not vacuous — I mutated the threshold comparison, the Normalize* match, and the measurement short-circuit, and all three were caught, including the negative [[ -s … ]] && fail assertions. What's missing is integration: nothing runs start, stop or finalize, so every one of these still passes green — deleting decide_normalize "$latest" from finalize_recording, deleting persist_normalize_preference from start, deleting the sidecar cleanup, and dropping -ss 0.1 or -vn from the measurement command. I confirmed the first and last by mutation.

What I checked and found correct. The two-pass loudnorm genuinely works: real ffmpeg 9.0.1 measured input_i=-41.91 on a quiet file, and feeding those five values back exactly as loudnorm_filter builds them produced −13.97 LUFS. Both passes see identical audio. Digital silence yields "input_i" : "-inf", which the numeric guard rejects, so silent recordings are left alone — better than quattro, which normalized them. ffmpeg prints the JSON object with braces at column 0, so the awk range works, and the omarchy-menu-select stub matches the real contract (empty glyph stripped, label<TAB>subtext returned). ./test/all is 207/208 with the fix; the one failure is theme-install-guards-test.sh, which this branch doesn't touch.

Two things worth measuring on real hardware before this ships, neither of which I can do from here. The extra analysis pass costs about 4.4s per 10 minutes of recording (timed on ffmpeg 9.0.1), so a 30-minute capture sits for roughly 13 seconds after stop with the bar indicator already gone and nothing on screen, then the dialog appears. And a sink monitor is captured post-volume, so desktop audio recorded at anything much below full volume lands under −18 LUFS — if that's right, the prompt fires on most recordings rather than the unusual ones, which is the opposite of the intent. One real recording each way would settle both.

Waiting on @ogarza for the stranding question and the flag-tier trim, and on @dhh for whether a blocking prompt belongs in the stop path at all.

…LE once and passes it through, another menu unblocks stop as keep original
@ogarza

ogarza commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

Kept the prompt in stop, moving it out still leaves a waiter, and you'd pay for a second encode if they say yes after the file is already “saved.”

The actual hang was openExistingMenu / openDmenu wiping doneFile without finishRequest. Image picker already does this in openSelector (finishDoneFile before the new request). Menu now finishes first, so Super+Space (or any other menu) unblocks stop as keep-original. Esc was already fine.

Also stopped re-reading RECORDING_FILE after finalize. It's captured once at the start of stop and used all the way through preview/cleanup, so a late answer can't toast or delete some other recording.

If nobody answers, we wait 120s then keep original levels. Killing the waiter left the dialog sitting there after the saved toast (hit that on a real stop), so timeout now also omarchy-menu close. Didn't put a timeout on omarchy-menu-select itself.

Dropped --normalize-audio / --no-normalize-audio altogether, not just the start sidecar. Nothing in the UI passed them, and OMARCHY_SCREENRECORD_NORMALIZE already covers skip-the-prompt. That also kills the env-vs-start-flag question. I tried to get too clever here, oops.

The Menu.qml fix is worth keeping even if we yank the prompt from stop later, transcode/timezone/webcam-pick all hung the same way on replace.

As for measuring on real hardware, I tested:

  • screencapture with mic, whispering = prompted as too quiet.
  • screencapture with mic, pretending to talk to someone on the couch next to me = not prompted.
  • screencapture with mic, pretending to curse loudly at someone on the couch next to me = prompted as too loud.
  • a talking youtube video at 100% volume = no prompted.
  • the same talking youtube video at 40% volume = prompted as too quiet.

As for the delay between stop and the normalize prompt: I tried a 30-minute recording here and it was a bad experience. The bar indicator was already gone, so I thought I wasn’t recording anymore and started another capture before the prompt even showed up.

I’d keep the current path for short files (say 10 minutes or less): analyze, and only ask if the levels actually look off. On longer files, ask right away with no analysis first. If they say yes, do a single loudnorm pass in the remux — same as we already do when normalize is always on. Short clips stay out of the way; after a long demo or cast, one extra click is fine, and you don’t sit there staring at a dead screen.

Thoughts on this @dhh ?

@ogarza

ogarza commented Aug 30, 2026

Copy link
Copy Markdown
Contributor Author

If you stop a recording and start another one before the save is fully done, like during that quiet pause after a long capture, we were wiping the new recording’s saved path. Next time you hit stop, we wouldn’t know which file to finish.

Now we only clear that path if it still belongs to the recording we just stopped. A new one that already started is left alone.

Also took --normalize-audio / --no-normalize-audio out of the PR description. Those flags aren’t a thing anymore; OMARCHY_SCREENRECORD_NORMALIZE is how you skip the prompt.

Still open: what to do about long recordings sitting there for a bit after you stop, before the normalize question shows up.

@ogarza

ogarza commented Aug 31, 2026

Copy link
Copy Markdown
Contributor Author

Over 10 minutes we skip the analysis and ask immediately: normalize to typical broadcast levels (Recommended), or keep original. Yes is a single loudnorm pass, same as always-on. Short files still measure first and only ask if the levels actually look off.

Unreadable duration falls through to analysis too.

@victorhugout

Copy link
Copy Markdown

Confirmed this fixes a real case on Omarchy 4.0.2-1 with gpu-screen-recorder 6.0.1-1 and the internal Realtek ALC3246 microphone.

After correcting excessive hardware gain, a direct PipeWire capture had a background noise floor around -54 dB. The standard screen-recording flow then applied loudnorm; a quiet section of the resulting recording measured around -15 dB, making the ambient noise clearly audible as static.

Keeping the startup-pop mute/fade but removing loudnorm resolved the issue: voice is clear and background static is gone. Asking before normalizing unusually quiet/loud recordings would have prevented this.

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.

5 participants