Skip to content

Recording fails at 1080p on slower machines: MJPEG is encoded as 4:4:4 in software; no way to lower resolution #3

Open

Description

@menobass

Problem

On a webcam that only offers 1080p as MJPEG, recording fails about a second in with:

Video encoding cannot keep up at this camera's maximum resolution. The take has been stopped and kept.

This happened on a modest machine, so it likely affects anyone with a slower CPU. Because the maximum resolution is always chosen and there is no way to change it, there is no way to work around it from the UI.

Setup: NexiGo N60 FHD webcam (1920×1080 only as MJPEG, 30 fps), Intel i5-8279U (8 threads), Omarchy, Qt 6.11.2, FFmpeg 9.0.1, Monologue 0.3.0.

Cause

Two things combine:

  1. The MJPEG frames reach Qt's encoder as compressed Format_Jpeg. Qt decodes them itself inside the encoder, and for this camera that produces 4:4:4 (yuvj444p). The Intel hardware H.264 encoders (VAAPI and QSV) cannot take 4:4:4, so Qt rejects them ("Could not initialize encoder" when forced) and falls back to software libx264. The resulting file was High 4:4:4 Predictive, 10-bit 4:4:4, which is very expensive to encode and also doesn't play in most browsers or phones.
  2. Writer fails the take once 6 frames are queued, which is what the 4:4:4 software encode hits within a second.

Rough numbers for 5 s of synthetic 1080p30 on this machine (ffmpeg, testsrc2): x264 4:4:4 10-bit took 6.5 s (slower than real time), x264 4:2:0 took 3.6 s, and VAAPI H.264 took 0.8 s.

Cameras with 4:2:2 or 4:2:0 MJPEG would be unaffected, which is probably why this isn't seen on faster hardware.

Proposed fix

  1. Decode the MJPEG frames in Writer and hand the encoder plain 8-bit 4:2:0 NV12. Do the decode and conversion on a small worker pool (not the GUI thread), keeping frames in order. The output is standard High-profile yuv420p.
  2. Add a resolution dropdown beside Camera and Microphone, listing the sizes the camera offers. The maximum stays the default and an explicit choice is remembered, so this doesn't change the "never silently reduced" behavior; it is only a user-chosen option.

I have this working and tested locally (a real 4 s take with a pause went from failing to completing at ~29 fps, and ./bin/test passes) and will open a PR.

Activity

  1. dhh commented on Nov 12, 2026

    @dhh
    Contributor

    #32 now hands the encoder 8-bit 4:2:0 frames. That lets VA-API apply on Intel, and it roughly halves the cost of software encoding if Qt still falls back to x264. Could you retest 1080p on current master? If it still stops, please run it with QT_FFMPEG_DEBUG=1 and paste which encoder opens. We've decided against a resolution menu to keep the controls minimal (see #14), but #19 does now skip camera modes that can't sustain 15 fps.

  2. hjbarraza commented on Nov 13, 2026

    @hjbarraza

    On Intel/AMD this is probably Qt 6.12.0 falling back to libx264 because it never selects VA-API. With a one-function Qt patch, a Celeron N4020 records 720p with hardware encoding at ~38% CPU. Details in #8: #8 (comment)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions