Repository navigation
v0.4.1
DemoLens 0.4.1 fixes four problems found by running 0.4.0 on a MacBook with ScreenCaptureKit: audio that started late, exports that came out shorter than the video, the stacking order of windows in the picker, and a way to see why a window is not listed.
The fixes were written against the numbers from that test and checked on Linux with synthetic recordings made to have the same shape (sound that starts a second after the picture). They have not been run on a Mac by the author. See "Check it on your Mac".
Fixes
- Audio that starts late (macOS). In the test,
demolens verifyreported the audio starting 778 ms after the video. The microphone takes a moment to open, and the recording clock used to start before ffmpeg was even launched. Now:- the shared clock starts when ffmpeg is launched, so the picture no longer carries the time spent opening the screen and listing microphones;
- when the recording is finished, the microphone is lined up with the picture: silence is put in front of a late start, an early start is trimmed, and a track that ends early is padded with silence. Only the audio is re-encoded, and only when it needs it. The picture is still copied;
- the sound stays where it really happened, so a voice that began 0.8 s in is still 0.8 s in, with silence before it.
- Clicks and zooms against the picture (macOS). Input events are logged on the same clock. If the first video frame arrives some time after that clock starts, the events, pauses and the webcam offset are moved earlier by that amount, so zooms still land on the right frame.
- Export was cut to the length of the audio. The export told ffmpeg to stop at the shortest stream, so a 7.5 s video with 6.7 s of sound came out as 6.7 s. The audio is now padded with silence to the full length and the video is never cut. This applies to MP4, WebM and the copy-only export.
- Old recordings. Export now reads where the audio and video really start in the source file. A recording made with 0.4.0 or earlier, whose sound starts late in the file, keeps its silence at the start instead of having the sound pulled to the beginning of the picture. Recordings from 0.4.1 are already lined up, so nothing extra is applied to them.
- Window stacking order (macOS). The picker used ScreenCaptureKit's list order as the stacking order. The direction was correct (a lower number is in front, and in the test Brave at 73 was in front of the DemoLens window at 89), but ScreenCaptureKit does not promise that order. The order now comes from the window server's own front to back list, and the numbers are consecutive ranks (0 is in front). If that list cannot be read, the old order is the fallback. There is a test for the ranking.
Changes
demolens sources --allalso prints every window ScreenCaptureKit reports, whether the picker lists it, and why not (not on screen, wrong layer, too small, DemoLens itself). The list is on screen, layer 0, at least 120 by 80 points. In the test only 2 of 107 windows were listed. The rest are expected to be menu bar items, the Dock, helper windows, and windows on other spaces or minimised, which stay hidden on purpose. Run it to confirm that on your machine.
Check it on your Mac
demolens record --screen 0 --mic --seconds 6, thendemolens verifyon the result.audio_offset_msshould be near 0 andissuesempty. Send the JSON if it is not.- Export it at 1080p and run
ffprobeon the output: the duration should match the video, not the audio. - Export an older recording that has late sound. The first part should be quiet, and the voice should start where it did in the recording.
demolens sources --all, with a few windows open and one in front. The front one should havez0 in the normal output, and the second list should show why anything missing is hidden.- Record with a click at the start and check the zoom lands on it.
Honest limits
- Only the audio and event timing code paths were tested, on Linux. The macOS code (the window server list, the clock start, the event shift) compiles on CI but has not run.
- The microphone's own start-up delay is real. The first moments of a recording made with a microphone may be silent for a few hundred milliseconds. That is now correct rather than shifted.
- The 40 ms tolerance means a track within 40 ms of the picture is left alone.
- System audio on macOS still needs a loopback device.