Repository navigation
Description
Summary
If a display is selected in the content picker and that display is later disconnected, BetterCapture will still start a recording against it. No video frames are ever captured, but because system audio/microphone are still flowing, the recording finalizes "successfully" and reports Recording saved. The resulting file contains only audio tracks and no video track at all.
I lost the video of a ~2 hour meeting this way, with no error or warning at any point.
Steps to reproduce
- Connect an external display.
- Open the content picker and select that display.
- Disconnect the external display (e.g. undock the laptop). Do not re-open the picker.
- Enable system audio and/or microphone capture.
- Start recording, let it run, stop recording.
Expected vs actual
Expected: the app notices the selected display no longer exists and either refuses to start with a clear message, or asks to re-select the capture source.
Actual: recording starts normally, the timer runs, and on stop a "Recording saved" notification appears. The output file has audio only.
Evidence
The affected recording (1h56m, 434 MB):
$ ffprobe -show_entries stream=index,codec_type,codec_name,width,height,nb_frames,duration ...
index=0
codec_name=aac
codec_type=audio
duration=6986.919979
nb_frames=327514
index=1
codec_name=aac
codec_type=audio
duration=6986.666667
nb_frames=327500
No video stream is present — not an empty or truncated one, it is absent entirely, meaning zero video frames were appended for the whole session. A normal recording from the previous day on the same install shows HEVC, 1920x1080 plus the audio tracks, so the setup itself is working.
Analysis
Reading through main (2559318), three things combine to make this silent:
1. The content filter is pinned to a displayID and never revalidated.
CaptureEngine stores the SCContentFilter from the picker and keeps it indefinitely. RecorderViewModel.canStartRecording (RecorderViewModel.swift:51) only checks selectedContentFilter != nil; there is no check that filter.includedDisplays.first?.displayID still corresponds to a connected display. There is also no display-reconfiguration handling anywhere in the codebase (no CGDisplayRegisterReconfigurationCallback, no NSApplication.didChangeScreenParametersNotification observer), so a disconnect never invalidates the selection.
2. The noFramesWritten guard is defeated by the audio path.
AssetWriter.finishWriting() guards on hasStartedSession (AssetWriter.swift:311), but appendAudioSample() also sets hasStartedSession = true on the first audio buffer (AssetWriter.swift:259-262). With audio enabled, the session is considered started even though frameCount is 0, so finalization succeeds and the "saved" notification is sent. The guard never looks at frameCount.
3. Nothing in the UI reveals the problem during recording.
The menu bar preview is a static thumbnail captured at selection time, so it keeps showing the old display's content, and live preview is stopped when recording starts (RecorderViewModel.swift:244).
Suggested fix
Two small, independent changes would each have prevented the data loss:
- Revalidate the filter in
startRecording()— fetchSCShareableContent.currentand confirm the selected display is still present before creating the stream. If it is gone, clear the selection and surface an error prompting re-selection. - Make the empty-video check meaningful — treat
frameCount == 0as a failure infinishWriting()rather than relying onhasStartedSessionalone. Important: this should warn and still save rather than callcancel(), sincecancel()deletes the output file and would also discard otherwise-valid audio.
A larger follow-up would be observing display reconfiguration so that a disconnect during an active recording is handled too (currently that case would produce a video track that silently stops partway).
I'm happy to open a PR for the two changes above if that direction sounds right.
Environment
- BetterCapture 2026.3 (
GitSHA 6124e54) - macOS 15.7.7 (24G720)
- MacBook Air (M1),
MacBookAir10,1 - Settings: MP4 / 30 fps, system audio + microphone enabled
Activity
fix: reject recording when the selected display is disconnected
fix: reject recording when the selected display is disconnected