Repository navigation
Give the encoder time to start before stopping the take - #43
0xBreadguy wants to merge 1 commit into
Conversation
[Medium impact] The change affects the recording path and how takes respond to slow encoder startup. The PR appears safe to merge, with two non-blocking improvements to the new recording tests. FindingsSummaryGives the encoder a bounded startup allowance before restoring normal recording limits.
Reviews (1) · Last reviewed commit: "Allow a bounded backlog while the encode..." · Reviewed by Greptile |
| QTest::qWait(35); | ||
| } | ||
| writer.finish(); QTRY_VERIFY_WITH_TIMEOUT(ended.count()>0,15000); | ||
| if(delayedFrame) { QVERIFY(!errors.isEmpty()); return; } |
There was a problem hiding this comment.
Unrelated errors pass the test
The already-recording case passes on any Writer::failed signal, even if recording fails before frame 60 reaches the encoder. That can hide an unrelated failure instead of checking that the later stall still stops recording. Assert that recording stays error-free until the delayed frame, then check for the expected backlog error.
| if(delayedFrame) { QVERIFY(!errors.isEmpty()); return; } | ||
| QVERIFY2(errors.isEmpty(),errors.isEmpty()?"":qPrintable(errors.first().first().toString())); | ||
| auto p=media::probe(directory.filePath("take.mp4")); QVERIFY2(p.ok,qPrintable(p.error)); | ||
| QVERIFY(p.audio); QVERIFY(std::abs(p.duration-3)<.1); |
There was a problem hiding this comment.
Shortened audio passes the test
The startup case checks all 90 video frames, but checks audio only through p.audio and the overall file duration. media::probe takes that duration from the file, not the audio stream, so shortened audio can still pass alongside three seconds of video. Check the audio stream duration or decoded sample count as well.
|
Works on my machine too, in the audio form of the same problem. On plain 0.4.0, both takes I tried stopped after about 0.4 s with "Audio encoding cannot keep up, so the take was stopped." That happened with and without EasyEffects on the microphone. With this PR applied on top of 0.4.0, every take records to the end. I made about ten takes today at 1920 × 1080 and 1280 × 720, between 5 and 10 s each, and none stopped.
|
|
I tested this branch on a Framework Laptop 13 Pro (Core Ultra X7 358H, Arc B390, qt6-multimedia 6.12.0-1), where Qt falls back to libx264 at 1080p. In the power-saver profile, 6 of 9 |
A 4K take can stop before the GPU encoder is ready. On the Intel/NVIDIA laptop in #42, Writer hits its queue limit about 0.52 seconds after recording starts. NVENC opens successfully at about 0.98 seconds, after Monologue has already stopped the take.
This gives the encoder a short startup allowance. For the first two seconds, Writer can queue up to 60 video frames and two seconds of audio. After that, the existing limits of six frames and 500 ms of audio apply again.
The queues stay bounded, and frames keep their order and capture timestamps. Recording stays at the selected resolution, including the start of the take. The tradeoff is a larger temporary budget for native-frame references during those first two seconds.
Fixes #42.
What was checked
The hardware check used an Intel Core Ultra 7 155H / RTX 4050 Laptop with Qt 6.12 and FFmpeg 9.0.2. It's a short check on one laptop/camera combination; longer takes and other encoder startup times still need testing.