Skip to content

Add a per-camera video format picker - #14

Closed
abort-retry-ignore wants to merge 4 commits into
omacom:masterfrom
abort-retry-ignore:format-picker
Closed

abort-retry-ignore wants to merge 4 commits into
omacom:masterfrom
abort-retry-ignore:format-picker

Conversation

@abort-retry-ignore

@abort-retry-ignore abort-retry-ignore commented Oct 19, 2026 •

Copy link
Copy Markdown

Fixes the "no way to lower resolution" half of #3.

The problem

Monologue always records at the camera's largest advertised resolution. On a Logitech C920 PRO that is 2560×1472, which the camera only offers as uncompressed YUYV and can only sustain at 2 fps over USB 2.0. The same camera does 1920×1080 MJPEG at 30 fps, but there is no way to ask for it: the selection logic ranks formats by pixel area alone and never considers frame rate or pixel format.

A resolution-only menu would not help here either, since the unusable mode is the largest one.

The change

  • A small label beside the camera name shows the current format; clicking it lists every format the camera advertises, largest first, as resolution, pixel format and the frame rate that will be requested (30 fps, or the format's limit if lower), with a checkmark on the active row. A 2 fps mode reads as 2 fps instead of hiding in a range.
  • The choice is stored per camera (cameraFormat/<id>) and survives restarts. Until one is picked, behavior is unchanged. If the camera stops offering the saved format, the default pick is used (covered by a unit test).
  • The control is disabled while a take is in progress, and the Space/Escape shortcuts ignore it while its popup is open, matching the camera and microphone controls.
  • bestCameraFormat had no remaining callers, so it is removed.

Testing

  • QT_FFMPEG_ENCODING_HW_DEVICE_TYPES=, ./bin/test: backend 20/20 and UI 3/3 pass, including new tests for the format label/key, the default pick, and saved-format fallback.
  • Without that variable, 7 backend tests (realEncoding, recoveryAndSave, editingAndExport, leavingDeletesTake, staleTakeIsNotRecovered, delayedCaptureStaysInSync) fail on this machine, identically on unmodified master. See the note below.
  • Real hardware, C920 PRO on Omarchy: the camera negotiates 1920 × 1080 · MJPEG · 30 fps (checked with v4l2-ctl), the choice persists across restarts, and ./bin/test-camera records a 4 s take at that format when the Qt hardware-encoder probing described below is disabled.

Note: an unrelated startup delay I ran into

On my machine (Qt 6.12, FFmpeg 9.0.2, RTX 4060 Ti, Ryzen 9 7900) a take at 1080p MJPEG stopped with "Audio encoding cannot keep up". I first assumed encoder throughput, but it looks like startup latency instead:

  • Qt's recorder tries each hardware encoder in turn before falling back to x264. Timed from the start of a take: NVENC fails at ~70 ms, VAAPI at ~270 ms, and Writer gives up at ~530 ms (its 500 ms queued-audio limit), before the software encoder has been opened.
  • Setting QT_FFMPEG_ENCODING_HW_DEVICE_TYPES before launch (to one backend, a pair, or empty) makes the same take record, and the failing realEncoding tests fail the same way at 320×240, which throughput cannot explain.
  • The variable is read once, so changing it after startup has no effect.

I have not verified that a longer startup allowance in Writer fixes it, and I only tried one machine, so I have left it out of this PR. It may be part of what #3 and #8 report on other machines.

Monologue always records at the camera's largest advertised resolution,
so a camera whose top mode is slow (a Logitech C920's 2560x1472 YUYV
mode delivers 2 fps) cannot be recorded at a usable frame rate, and
there is no way to choose otherwise.

A Format control beside the camera lists every format the camera
advertises, largest first, with resolution, pixel format, and frame
rate, and marks the active one. The choice is stored per camera and
survives restarts, falling back to the existing maximum-resolution
default when the camera no longer offers it.
The picker listed each format's full advertised range ("5–30 fps"), which
says nothing about the rate the recording will actually use. Show the rate
the app requests instead, so a 2 fps mode is obviously the one to avoid and
every other row reads as a single rate.

Show the selected format itself beside the camera rather than the word
"Format".
A saved format that the camera stopped advertising matched nothing, so the
picker landed on the first (largest) entry instead of the default pick.
Choose the saved format, then the default, then the first, in one small
tested function, and remove bestCameraFormat, which the picker made unused.
Give the camera name its full width back and show the selected format in a
small, capped label so the two no longer overlap. Restore the original Space
handler: the earlier edit was equivalent, because a take's writer is gone
before the editor state is entered.
@dhh

dhh commented Nov 12, 2026

Copy link
Copy Markdown
Contributor

Thanks for digging into this, and for the C920 PRO details. #19 now fixes the default: modes slower than 15 fps lose to a smoother one, so the C920 PRO opens at 1920×1080 MJPEG 30 fps without a picker. We'd like to keep Monologue's controls minimal, so I'm closing this. The 'encoding cannot keep up' delay you traced to Qt probing hardware encoders is fixed in #37, and the 4:2:0 encoding in #32 lets NVENC and VA-API apply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants