Repository navigation
libobs, frontend: Count encoding lag of encoders that rescale the output - #337
Merged
zackees merged 2 commits intoOct 12, 2026
Merged
Conversation
With Rescale Output on, Stats shows "Skipped frames due to encoding lag" as 0 / 0 and the status bar never warns that the encoder is overloaded. Both read the counters of obs_get_video(), the main video mix. An encoder with a GPU scaled size gets its own encoder-only video mix (maybe_set_up_gpu_rescale() in obs-encoder.c), and that mix's video_t counts its frames, so the main mix stays at 0 / 0. obs-websocket's GetStats reads the same counters. obs_get_video_frame_counts() is meant to report the main canvas's frames wherever they are encoded. This commit adds it with the behaviour the frontend has today (the main mix only), and test_encoding_lag_rescale, which starts a raw video encoder on a 64x64, 30 fps canvas and reads the counts while it runs for 1.5 s: unscaled 45 frames, 0 skipped ok unscaled, 100 ms per frame 15 frames, 8 skipped ok rescaled to 32x32 0 frames, 0 skipped FAIL rescaled, 100 ms per frame 0 frames, 0 skipped FAIL two rescaled, one shared mix 0 frames FAIL encoder on a second canvas 0 counted ok (guard) libobs itself logs "skipped frames due to encoding lag: 21/34" for the rescaled mix when it stops; only the main mix's counters are read. The test needs core video, so it is registered on Linux only, loads the built libobs-opengl and skips without a display. Reported upstream by nickcharlesyt in obsproject/obs-studio#11078, by TheMasterofBlubb in #10744, by walker-WSH in #11551 (with the cause) and by CatKasha in #11907 (the missing overload warning). Refs obs-rust#336 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With Rescale Output on, Stats showed "Skipped frames due to encoding lag" as 0 / 0, and the status bar never warned that the encoder was overloaded. Both read the counters of obs_get_video(), the main video mix, but an encoder with a GPU scaled size encodes from its own encoder-only mix (maybe_set_up_gpu_rescale()), whose video_t counts the frames instead. obs_get_video_frame_counts() now sums the counters of the main canvas's mix and of the encoder-only mixes made for that canvas's rescaling encoders, each mix once. It reads them under mixes_mutex, the lock an encoder-only mix is freed under when its last encoder stops, so a caller never reads a mix that is going away. Mixes of other canvases and views (a vertical canvas plugin, or the virtual camera set to a single scene) are not counted, as derrod asked for on obsproject/obs-studio#10866. Stats and the status bar call it instead of reading obs_get_video(). A rescaling encoder's mix and its counts go away when it stops, so the status bar now starts counting again when the totals drop, as Stats already did; before, its baseline could stay above the totals and hide the warning for the rest of the session. test_encoding_lag_rescale: 3 of 6 cases failed, 6 of 6 pass. A rescaled encoder now counts 45 frames in 1.5 s (was 0), a rescaled encoder at 100 ms per frame 15 frames with 8 skipped (was 0 / 0), and two encoders sharing one rescale mix 45 frames, counted once. Reported upstream by nickcharlesyt in obsproject/obs-studio#11078, by TheMasterofBlubb in #10744, by walker-WSH in #11551 and by CatKasha in #11907; ArnavMehrotra traced it to the two video_t objects. Earlier attempts: #10866 and #10867 by deltamaya (closed). No upstream code is used. Fixes obs-rust#336 Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]> Local-Gate: v1 tree=1cbbdaf0d036191445d26db64ae927312322eef6 secs=141 lanes=lint:run,rust-test:run,tier2-linux:run Ci-Attestation: {"at":1791791131,"gate":"rust/all/fmt","host":"linux-x86_64","key":"d365f8ea5803da891b31f1af56fddc53e745f261df1a2460d4d833673aa71f76","lane":"lint","parents":["8c6d2dbf7fc547f78798f22803218cf621f0a07c"],"secs":52,"stamp":"b7d2d33fb9abe938c0d20a4c43fa9ad9","tree":"1cbbdaf0d036191445d26db64ae927312322eef6","v":1,"via":"run"} Ci-Attestation: {"at":1791791131,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"d365f8ea5803da891b31f1af56fddc53e745f261df1a2460d4d833673aa71f76","lane":"lint","parents":["8c6d2dbf7fc547f78798f22803218cf621f0a07c"],"secs":52,"stamp":"3a1c3e258e53f76737b9aa6e6a58a8b8","tree":"1cbbdaf0d036191445d26db64ae927312322eef6","v":1,"via":"run"} Ci-Attestation: {"at":1791791131,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"e6fb7384bbefdfa9cc3542430db69d032ed776008f6e702eb9e8f6a301fe0fab","lane":"rust-test","parents":["8c6d2dbf7fc547f78798f22803218cf621f0a07c"],"secs":46,"stamp":"c1d7a1b165fb9e1a0537a26054ad495a","tree":"1cbbdaf0d036191445d26db64ae927312322eef6","v":1,"via":"run"} Ci-Attestation: {"at":1791791131,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"d74dc4408a63cc7560b1237dbbcc04a62973327fa93ba2a5882b8e6aa76cec99","lane":"tier2-linux","parents":["8c6d2dbf7fc547f78798f22803218cf621f0a07c"],"secs":42,"stamp":"b5f998d8dfb7776a159dae854f4d2c44","tree":"1cbbdaf0d036191445d26db64ae927312322eef6","v":1,"via":"run"}
Member
|
Verified locally, rebased onto master and stamped. The test needs a display, so I ran it with
Note for reviewers: this adds a public libobs API ( |
zackees
force-pushed
the
fix/11078-rescale-skipped-frames
branch
from
October 12, 2026 07:45
88752f0 to
b771a8b
Compare
This was referenced Oct 12, 2026
zackees
pushed a commit
to rdoupe/obs-studio
that referenced
this pull request
Oct 14, 2026
obs-rust#337 made OBS's Stats dock and status bar count the frames of encoders that rescale the output (Rescale Output), which encode from a video mix of their own. obs-websocket's GetStats still read obs_get_video(), the main mix, so while only a rescaled recording ran it reported outputSkippedFrames / outputTotalFrames = 0 / 0. obs-rust/obs-websocket#4 takes both values from obs_get_video_frame_counts(), like the Stats dock. That fix already shipped with the submodule pin to 547f5ea; this adds the regression test. Add a Tier 4 phase: the suite can now start OBS on a profile written before launch, and "stats with Rescale Output" records at 640x360 from a 1280x720 canvas for 3 seconds and checks that GetStats counts the frames. It retries StartRecord while the server answers 207 (NotReady) during frontend startup. OBS is now started with --multi, so another OBS on the same machine does not hold it at the single-instance dialog. The phase fails with 0 / 0 with the submodule at caf0527, the fork commit before obs-rust#4 was merged, and passes at 547f5ea. Refs obs-rust#514. Co-Authored-By: Claude Opus 5.5 <[email protected]> Local-Gate: v1 tree=2586eb5231297f7e5ac0663ab8afd50d7755feea secs=528 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1792004952,"gate":"rust/all/fmt","host":"linux-x86_64","key":"fb9af536766902129ece46b231d51d356c88cd44b7a4ae4278693b9589973c1d","lane":"lint","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":53,"stamp":"522c5232d38c5379b2dbdf95d6745ae5","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"fb9af536766902129ece46b231d51d356c88cd44b7a4ae4278693b9589973c1d","lane":"lint","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":53,"stamp":"f72e64d0d7ce082ae99190cd946305de","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"f82a96a3ebf8185e9afc6a6936d54c407534dcd196aae1a51d822fd4982f8c3f","lane":"rust-test","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":121,"stamp":"211b88942d2ba50ac8803d0a66ddb031","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"d479cf2a3ac23b07a86c528e60bee7f4","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"a48f50b7437a052e74e2aa246a68bc7a","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"2b3f87af06084f79f56949749d6f7c82","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"c5a41a7056c65e335124d197bda80fd4","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"f85c003f8e3ecc00d28d7870ed9b8e24","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"89a7bf52adb3b008dd2dd6eeb5cfdb92","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"c0c4ea416ea70ee6dcb2acee436be364dea927882183c8c32e588e15bab63775","lane":"tier2-linux","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":244,"stamp":"9c59ada4512d7f5b22fc44fe799716d9","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"}
zackees
pushed a commit
to chriscoveries/obsrust-fork
that referenced
this pull request
Oct 14, 2026
…-rust#751) obs-rust#337 made OBS's Stats dock and status bar count the frames of encoders that rescale the output (Rescale Output), which encode from a video mix of their own. obs-websocket's GetStats still read obs_get_video(), the main mix, so while only a rescaled recording ran it reported outputSkippedFrames / outputTotalFrames = 0 / 0. obs-rust/obs-websocket#4 takes both values from obs_get_video_frame_counts(), like the Stats dock. That fix already shipped with the submodule pin to 547f5ea; this adds the regression test. Add a Tier 4 phase: the suite can now start OBS on a profile written before launch, and "stats with Rescale Output" records at 640x360 from a 1280x720 canvas for 3 seconds and checks that GetStats counts the frames. It retries StartRecord while the server answers 207 (NotReady) during frontend startup. OBS is now started with --multi, so another OBS on the same machine does not hold it at the single-instance dialog. The phase fails with 0 / 0 with the submodule at caf0527, the fork commit before #4 was merged, and passes at 547f5ea. Refs obs-rust#514. Local-Gate: v1 tree=2586eb5231297f7e5ac0663ab8afd50d7755feea secs=528 lanes=lint:run,rust-test:run,cross:run,tier2-linux:run Ci-Attestation: {"at":1792004952,"gate":"rust/all/fmt","host":"linux-x86_64","key":"fb9af536766902129ece46b231d51d356c88cd44b7a4ae4278693b9589973c1d","lane":"lint","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":53,"stamp":"522c5232d38c5379b2dbdf95d6745ae5","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"fb9af536766902129ece46b231d51d356c88cd44b7a4ae4278693b9589973c1d","lane":"lint","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":53,"stamp":"f72e64d0d7ce082ae99190cd946305de","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"f82a96a3ebf8185e9afc6a6936d54c407534dcd196aae1a51d822fd4982f8c3f","lane":"rust-test","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":121,"stamp":"211b88942d2ba50ac8803d0a66ddb031","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-pc-windows-msvc/clippy","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"d479cf2a3ac23b07a86c528e60bee7f4","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-pc-windows-msvc/dylint","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"a48f50b7437a052e74e2aa246a68bc7a","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/aarch64-apple-darwin/clippy","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"2b3f87af06084f79f56949749d6f7c82","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/aarch64-apple-darwin/dylint","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"c5a41a7056c65e335124d197bda80fd4","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-apple-darwin/clippy","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"f85c003f8e3ecc00d28d7870ed9b8e24","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"rust/x86_64-apple-darwin/dylint","host":"linux-x86_64","key":"525209b94219c953eac4c0a7dc73aa9c42c3767378810ea5160b1b49650d3bfa","lane":"cross","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":109,"stamp":"89a7bf52adb3b008dd2dd6eeb5cfdb92","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Ci-Attestation: {"at":1792004952,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"c0c4ea416ea70ee6dcb2acee436be364dea927882183c8c32e588e15bab63775","lane":"tier2-linux","parents":["d9328f4c24bb4ceb49c67e3abb0cd4d74b453f2e"],"secs":244,"stamp":"9c59ada4512d7f5b22fc44fe799716d9","tree":"2586eb5231297f7e5ac0663ab8afd50d7755feea","v":1,"via":"run"} Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
With Rescale Output on, Stats now counts "Skipped frames due to encoding lag", and the status bar warns again when the encoder is overloaded.
obs_get_video(), the main video mix. An encoder with a GPU scaled size (Settings > Output > Rescale Output, and the encoders of Enhanced Broadcasting and WHIP simulcast) encodes from its own encoder-only mix, made bymaybe_set_up_gpu_rescale(). That mix'svideo_tcounts the frames, so the main mix stayed at 0 / 0 and the overload warning never fired. libobs itself logged the skipped frames for the rescaled mix when the output stopped. Nothing else read them.test/cmocka: Add failing test for encoding lag with Rescale Output: addsobs_get_video_frame_counts()with the behaviour the frontend has today (the main mix only) andtest_encoding_lag_rescale. The test starts an output with a raw video encoder on a 64x64, 30 fps canvas and reads the counts while it runs for 1.5 s. The cases are:Today the three rescaled cases see 0 frames and 0 skipped. The guards see 45 frames, 15 frames with 8 skipped, and 0. 3 of 6 fail.
libobs, frontend: Count encoding lag of encoders that rescale the output:obs_get_video_frame_counts()sums the counters of the main canvas's mix and of the encoder-only mixes made for that canvas's rescaling encoders, each mix once. It reads them undermixes_mutex, the lock an encoder-only mix is freed under, so a caller never reads a mix that is going away. Mixes of other canvases and views are not counted. Stats and the status bar call it instead of readingobs_get_video(). A rescaling encoder's mix goes away when it stops, so the status bar now starts counting again when the totals drop, as Stats already did. The function is documented inreference-core.rst. The rescaled cases now count 45 frames, 15 frames with 8 skipped, and 45 frames once. 6 of 6 pass.Motivation and Context
Fixes #336 (upstream obsproject/obs-studio#11078, reported by nickcharlesyt, with a video; ArnavMehrotra reproduced it on macOS and traced it to the two
video_tobjects). The same bug is reported in obsproject/obs-studio#10744 by TheMasterofBlubb, in obsproject/obs-studio#11551 by walker-WSH, who pointed tomaybe_set_up_gpu_rescale(), and in obsproject/obs-studio#11907 by CatKasha, for the missing overload warning.Two earlier upstream attempts by deltamaya were closed without being merged:
This PR keeps derrod's boundary (only the main canvas is counted) but does the counting in libobs, where the mixes' lock is. It counts every encoder of the main canvas once, whichever output it belongs to. No upstream code is used.
Why this one: "Skipped frames due to encoding lag" and the "encoding overloaded" warning are how people find out that their encoder cannot keep up. With Rescale Output, a common setting for streaming at a lower resolution than the canvas, both went silent, and a stream or recording could drop most of its frames with no warning. Four reports since 2024.
How Has This Been Tested?
Automated, in both libobs lanes (
ENABLE_RUST_LIBOBSOFF and ON), on current master:test_encoding_lag_rescale: 3 of 6 cases fail at the RED commit and 6 of 6 pass at GREEN, in both lanes. All six cases run (about 12 s, no SKIPPED lines inctest -V) under a private Xvfb with software GL. The test loads the built libobs-opengl (GRAPHICS_MODULE_PATH), and it was run with an installed system OBS's GL module hidden, as on CI. GREEN passed three runs in a row in each lane.ENABLE_FRONTEND=ON) builds, including both changed widgets, with no new warnings.ci/test_registration.pyare clean. The test is registered Linux-only, with the working directory inside the guard.Not tested:
obs_get_video_frame_counts()where it readobs_get_video()before, and the status bar's new restart of its count when the totals drop is untested.video_output_inc_texture_frames()on the same mix'svideo_t, which this reads the same way, but no texture encoder ran here.GetStats(outputSkippedFrames,outputTotalFrames) still readsobs_get_video()and still shows 0 / 0 with Rescale Output. It lives in the obs-websocket submodule and can switch to the new function in a follow-up.Types of changes
Checklist:
🤖 Generated with Claude Code