Repository navigation
Conversation
Webcams deliver 4K30 as MJPEG. Qt decoded each frame to RGB and then encoded it as 10-bit 4:4:4 H.264, which most players cannot open and which is far slower to encode. Decode with libjpeg-turbo straight to video-range YUV 4:2:0 on the thread pool, keeping frames in capture order. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Qt's recorder always runs libx264 at its medium preset, which manages about 17 fps at 4K, and never uses VAAPI for frames in system memory, so 4K takes stopped within seconds. Encode on a worker thread with FFmpeg: the GPU's h264_vaapi encoder when available, otherwise libx264 at veryfast. Takes keep the same timing model and MP4 output. Fixes omacom#8 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks for this. I ran the branch on an Intel Core Ultra X7 358H with Arc B390 (FFmpeg 9.0.2), and a 4K take holds on h264_vaapi. I have two small commits that apply on top of f9f346e. I would rather offer them for this branch than open a second pull request:
./bin/test passed here: 24 backend tests and 3 UI tests, including the bad-JPEG cases, level 4.2 with no B-frames at 320×240, and a forced libx264 fallback. ./bin/test-camera produced a 4.0 s 3840×2160 clip: High, yuv420p, level 5.1, no B-frames, encoder tag h264_vaapi, with AAC for the whole take. The frame count was 100, about 25 fps. That matches what you already noted: this branch alone can still drop frames on the slot grid, which is #9. Happy to open a pull request against fix-4k-recording with just those two commits if you want them here. |
|
Thanks for digging into this! The 4:4:4 / software-encode problem is being fixed in #32, which hands Qt's recorder 8-bit 4:2:0 frames (MJPEG decoded with libjpeg-turbo, like here) so it picks a hardware H.264 encoder, without replacing |
Fixes #8. Also addresses the encoder half of #3: its 4:4:4 output and software-only encoding.
What changed
media::decodeJpeg): webcams deliver 4K30 as MJPEG. Each frame is decoded with libjpeg-turbo straight to the JPEG's own planes, box-filtered to 8-bit 4:2:0 and converted to video range, on the Qt thread pool, keeping capture order. Output is standard H.264 High profileyuv420pinstead of 10-bit 4:4:4.QMediaRecorder(src/encoder.cpp): a worker thread encodes H.264/AAC into the MP4 withh264_vaapi(CQP 20) when available, otherwiselibx264 -preset veryfast -crf 19.Writerkeeps its timing model (pause intervals, sample-counted audio with padding and trimming), its failure messages and its backpressure limits;Backendis unchanged.libjpeg-turbo(README, PKGBUILD). FFmpeg's libraries were already required.Verification
Beelink SER8 (Ryzen 7 8745HS, Radeon 780M), Omarchy 4.0.4, Qt 6.11.2, FFmpeg 9.0.1, Logitech MX Brio at 3840×2160 MJPEG 30 fps.
./bin/test: all pass (22 backend + 3 UI). This includes the A/V sync test (within 10 ms), new decoder tests for 4:2:2, 4:2:0, 4:4:4 and grayscale JPEGs, and a check that the encoded output is Highyuv420p../bin/test-cameraand a 59 s real 4K take: completed without stopping, Highyuv420p. Before this change, takes stopped after 1–3 s.Frame counts on this branch alone can still be low in some takes; that's #9, fixed separately in its own PR. Both PRs touch the first lines of
Writer::videoAt, so whichever merges second will need a small rebase.🤖 Generated with Claude Code