omarchy icon indicating copy to clipboard operation
omarchy copied to clipboard

Screen recordings with audio are written at 96 kHz AAC (loudnorm missing -ar)

Open davidstillson opened this issue 2 months ago • 2 comments

What happened

Every screen recording made with audio is written at 96 kHz AAC instead of the 48 kHz that gpu-screen-recorder captured.

96 kHz AAC is unusual enough to be poorly supported downstream. DaVinci Resolve reads the container metadata correctly (reports AAC, 2ch, Sample Rate 96000) but decodes no samples — the clip imports and the video scrubs and plays fine, while the audio is silent and the timeline waveform is a blank rectangle. It also costs bitrate for no benefit, since the source audio was 48 kHz.

What I expected

Recordings keep the 48 kHz sample rate they were captured at.

Root cause

bin/omarchy-capture-screenrecording, in finalize_recording() (line 271):

args+=(-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")

ffmpeg's loudnorm analyses at 192 kHz and declares that as its output rate. With no -ar on the command, ffmpeg negotiates that rate with the AAC encoder, which caps at its own 96 kHz ceiling — so the finalize pass silently resamples 48 kHz up to 96 kHz.

gpu-screen-recorder is not at fault; the file is correct until finalize_recording() runs.

Steps to reproduce

Independent of the recorder — this reproduces with plain ffmpeg:

# stand in for a gsr recording: 48 kHz AAC
ffmpeg -y -f lavfi -i testsrc=size=320x240:rate=60 \
       -f lavfi -i "sine=frequency=440:sample_rate=48000" \
       -t 3 -c:v libx264 -c:a aac -ar 48000 gsr_sim.mp4

# exactly what finalize_recording() runs
ffmpeg -y -ss 0.1 -i gsr_sim.mp4 -c:v copy \
  -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" \
  gsr_finalized.mp4

ffprobe -v error -select_streams a -show_entries stream=codec_name,sample_rate -of csv=p=0 gsr_sim.mp4
ffprobe -v error -select_streams a -show_entries stream=codec_name,sample_rate -of csv=p=0 gsr_finalized.mp4

Result:

gsr output (before finalize):  aac,48000
after finalize_recording():    aac,96000
same chain minus loudnorm:     aac,48000   # isolates loudnorm as the cause

Or end to end: omarchy screenrecord --fullscreen --with-desktop-audio, stop it, then ffprobe the file.

Suggested fix

Pin the output rate — add -ar 48000 to that invocation. Loudness normalization is unaffected; a -21.1 dB source still lands at -13.6 dB against the -14 LUFS target.

Happy to open a PR.

System details

  • Omarchy 4.0.2-1
  • gpu-screen-recorder 6.0.1
  • ffmpeg n9.0.1
  • Arch Linux, kernel 7.1.9-arch1-2
  • AMD Radeon RX 7900 XTX (amdgpu)

davidstillson avatar Sep 09 '26 12:09 davidstillson

This is fixed on quattro but not yet released. e1b0e5e9b (#14431) adds -ar 48000 to the loudness pass in finalize_recording() (bin/omarchy-capture-screenrecording:489), exactly as you suggested, along with a regression test, test/shell.d/screenrecording-sample-rate-test.sh, which runs the real function on a 48 kHz recording and checks that the sample rate is still 48 kHz afterwards. v4.0.4 still has the old line, so the fix will reach you in the next release.

I checked it on a fresh Omarchy worker with ffmpeg n9.0.1. Your ffmpeg reproduction gives aac,96000 without -ar and aac,48000 with it. The regression test passes on current quattro and fails with 96000 when the -ar 48000 is taken out. This is the only loudnorm in the repository, and no other ffmpeg call uses a filter that changes the sample rate.

Codex Medium reviewed this separately and came to the same conclusion: same mechanism, same fixing commit, not yet in a tag. It had read access to this session's notes, so its agreement isn't a fully independent check.

Nothing is needed from you. The maintainer will decide whether to close this now or when the release ships.

omarchybot avatar Oct 11 '26 10:10 omarchybot

Fixed on quattro (#14431) — finalize_recording now pins -ar 48000, with test/shell.d/screenrecording-sample-rate-test.sh. Not in v4.0.4 yet; will clear on the next release.

jandrusk avatar Oct 13 '26 16:10 jandrusk