omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Screen recordings with audio glitch ~3 s before the end (dynamic loudnorm EOF flush in finalize_recording)

Open EY3G0R3 opened this issue 1 month ago • 1 comments

System details

AMD Ryzen AI 9 HX PRO 370 (Radeon 890M), Omarchy 4.0.4, gpu-screen-recorder 6.1.0, ffmpeg 9.0.1

What's wrong?

Screen recordings made with desktop or microphone audio sometimes end with a loud spike about 3 seconds before the end. It is sometimes followed by ~10 Hz clicking that runs to the last frame. The raw gpu-screen-recorder output is clean. The artifact comes from the loudness pass in finalize_recording(), and it is still present on main:

args+=(-ar 48000 -af "volume=enable='lt(t,0.4)':volume=0,afade=t=in:st=0.4:d=0.05,loudnorm=I=-14:TP=-1.5:LRA=11")

Cause. Without measured values, loudnorm runs in dynamic mode: 100 ms frames with a 3 s lookahead buffer. At EOF it flushes that buffer with gain steps it never gets to smooth. That is why the spike lands one buffer length before the end, and why the clicking is ~10 Hz. This is separate from the 96 kHz issue in #10970; the -ar 48000 from that fix doesn't change it.

Reproduce.

  1. Record ~10 s with desktop audio while something with varying loudness plays (speech or music; a steady sine does not trigger it).
  2. Stop, then look at the last few seconds: ffmpeg -sseof -4 -i FILE -vn -lavfi showwavespic=s=1200x200 tail.png

It depends on the content, so some recordings come out clean. On one 10 s raw gsr capture with desktop audio:

Input Result
Raw gsr capture clean
Through the current main finalize chain -1.0 dBFS spike at 6.7 s of 9.7 s (3.0 s before the end)
Through the padded chain below clean, length trimmed to the video

Suggested fix. Pad 3 s of silence ahead of loudnorm so its EOF flush happens on padding, and trim the padding with -shortest:

-    args+=(-ar 48000 -af "volume=enable='lt(t,0.4)':volume=0,afade=t=in:st=0.4:d=0.05,loudnorm=I=-14:TP=-1.5:LRA=11")
+    args+=(-ar 48000 -af "volume=enable='lt(t,0.4)':volume=0,afade=t=in:st=0.4:d=0.05,apad=pad_dur=3,loudnorm=I=-14:TP=-1.5:LRA=11" -shortest)

A side effect: audio now ends with the video instead of running ~0.1–0.2 s past it. I've been running this locally on 4.0.4 (equivalent line, without -ar), and recordings through the real start/stop flow come out clean. A two-pass loudnorm (measure, then linear=true with the measured values) would avoid dynamic mode entirely, but it needs a second decode pass at stop time.

EY3G0R3 avatar Oct 14 '26 09:10 EY3G0R3

Thanks for the detailed report. I read it against quattro (c39fd2af): the loudnorm=I=-14:TP=-1.5:LRA=11 line in finalize_recording() in bin/omarchy-capture-screenrecording is unchanged there, with no measured values, so it still runs in dynamic mode as you describe. I have not reproduced the spike yet.

#15445 proposes the padded chain from this report and is already linked to close this issue, so the fix will be reviewed and tested there as its own pull request.

This issue is not labelled yet. Classification takes two models deciding separately, and only Opus 5.5 ran this time: the second opinion (Codex) was not asked because the day's review budget was spent. It will be classified again on a later pass. Nothing is needed from you.

omarchybot avatar Oct 22 '26 12:10 omarchybot