Skip to content

libobs: Report no video from obs_get_video_info before obs_startup - #1565

Merged
zackees merged 3 commits into
obs-rust:masterfrom
rdoupe:fix/1509-video-info-before-startup
Oct 20, 2026
Merged

zackees merged 3 commits into
obs-rust:masterfrom
rdoupe:fix/1509-video-info-before-startup

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 20, 2026

Copy link
Copy Markdown
Collaborator

Fixes #1509 (with #1562, which fixed the uninitialized fields; this is the crash before obs_startup)

What and why

obs_get_video_info now returns false before obs_startup, so os_generate_formatted_filename formats a name normally there. Before, obs_get_video_info dereferenced the NULL core (obs->video.graphics), and since the file name helper reads the video info for every format, a plugin or libobs-based tool that named a file before starting libobs crashed (SIGSEGV), even with no video specifier in the format.

  • The check is one !obs || in obs_get_video_info (libobs/obs.c.h), the way obs_reset_video and obs_reset_audio guard the core next to it. false is the documented "no video" result, which callers already handle; with util: Zero the video fields of a formatted filename with no video #1562 it formats %FPS, %CRES, %ORES and %VF as 0, 0x0, 0x0 and None. No other getter changes.
  • Not in the helper: skipping the call for a format with no video specifier would change the C and the Rust "read once, before the format is looked at" behavior that test_formatted_filename and the Tier 3 parity test pin, and a format with a video specifier would still crash.
  • libobs-with-rust: obs-util::platform_filename's os_generate_formatted_filename calls the same C obs_get_video_info (there is no Rust port of it), so the fix covers both libraries. Its # Safety note no longer says libobs must be started.
  • No caller in the tree reaches this: the recording outputs and the frontend format names with video up.
  • Upstream OBS has the same code. Nobody has reported it there, so there is no upstream issue.
  • No docs/features.md line here: util: Zero the video fields of a formatted filename with no video #1562's line for bug: util: os_generate_formatted_filename uses video info that obs_get_video_info did not fill #1509 covers the user-visible part. When both are in, it can say the call also works before libobs is started.
  • rust/README.md's platform-filename row still says "Before obs_startup both crash in obs_get_video_info". util: Zero the video fields of a formatted filename with no video #1562 rewrites that row, so this PR leaves it, to avoid a conflict; whichever lands second drops that sentence.

Headless (private Xvfb, private D-Bus, fresh HOME):

Build Case Result
master 1d26efc test_platform with the RED test, both lanes, against libobs and libobs-with-rust test_formatted_filename_before_startup fails (child killed by signal 11), 30/31 pass
This branch test_platform, both lanes, both libraries 31/31 pass
This branch full ctest, both lanes, both libraries 340/340, none skipped (one setup failure in test_audio_controls, C lane against libobs, unrelated; 5/5 on rerun)

RED → GREEN

  • RED commit: d6acc9a test: Format a file name before obs_startup. A new case in test_platform (it links the real libobs; test_formatted_filename replaces obs_get_video_info with a fixture) calls obs_get_video_info and os_generate_formatted_filename("mkv", true, "before startup") before obs_startup, in a child process, and expects false and "before startup.mkv". On master the child dies with SIGSEGV, so test_platform fails 1 of 31, in the C lane (ENABLE_RUST_LIBOBS=OFF) and the libobs-with-rust lane (ON), each against both libobs and libobs-with-rust.
  • GREEN: 5dec501. test_platform 31/31 in both lanes against both libraries. Full ctest 340/340 in both lanes against both libraries, none skipped (before the rebase onto 5310fed; one run, C lane against libobs, had a test_audio_controls setup failure, an audio-only test that does not call this code, which passed 5/5 on rerun). After the rebase, test_platform, test_formatted_filename and test_audio_controls pass 3/3 in both lanes against both libraries. Exported symbols of the two libraries identical (1766). uv run ci/local_gate.py --lane lint, cross, cross-release, rust-test: ok.
  • Real app: no UI or log change. The app starts libobs before it formats any name.

Checklist

  • Base is master
  • I claimed the issue, or no one else has an open PR for it
  • Characterization test (if the unit had none), then RED, then GREEN commits
  • User-visible change: its line in docs/features.md is added or updated (not applicable: util: Zero the video fields of a formatted filename with no video #1562's line for bug: util: os_generate_formatted_filename uses video info that obs_get_video_info did not fill #1509 covers it)
  • (Optional) Local gate passed and the pushed head is stamped; otherwise PR CI runs the full suite
  • Warning or flag changes (-W..., ratchets): built with scripting ON (a flag change under cmake/ or build-aux/ runs the full builds) and cross-checked with clang and MSVC (not applicable: no flag change)
  • Intentional differences from C listed in the parity test header and rust/README.md (ports) (not applicable: no new difference; both libraries call the same C function)

os_generate_formatted_filename reads the video info first, for every
format, and before obs_startup the real obs_get_video_info dereferences
the NULL core. So a name with no video specifier crashes a plugin or
libobs-based tool that formats it before starting libobs.

test_formatted_filename replaces obs_get_video_info with a fixture, so
this goes in test_platform, which links the real libobs: before
obs_startup, obs_get_video_info must return false (no video) and
"before startup" must format as "before startup.mkv". The call runs in
a child, so the crash fails this test only.

Refs obs-rust#1509
Before obs_startup there is no core, and obs_get_video_info dereferenced
the NULL obs. os_generate_formatted_filename reads the video info for
every format, so a plugin or libobs-based tool that named a file before
starting libobs crashed, even with no video specifier in the format.

Return false, the documented "no video" result, when there is no core,
as obs_reset_video and obs_reset_audio check it. Callers already handle
false. libobs-with-rust's os_generate_formatted_filename calls the same
C function, so both libraries format the name normally.

Fixes obs-rust#1509
@rdoupe
rdoupe requested a review from zackees as a code owner October 20, 2026 21:59
…obs_startup

The row said that a formatted file name crashes in obs_get_video_info
before obs_startup. With the guard in the previous commit that call
returns false, so C and Rust both give the zeroed video fields.

Refs obs-rust#1509
@zackees
zackees enabled auto-merge October 20, 2026 22:12
@zackees
zackees added this pull request to the merge queue Oct 20, 2026
Merged via the queue into obs-rust:master with commit 0b7fd6a Oct 20, 2026
23 checks passed
rdoupe added a commit to rdoupe/obs-studio that referenced this pull request Oct 21, 2026
It was merged with a literal #PR placeholder. The fix landed in obs-rust#1562
(zeroed video fields) and obs-rust#1565 (no crash before obs_startup).

Refs obs-rust#1611
chriscoveries pushed a commit to chriscoveries/obsrust-fork that referenced this pull request Oct 21, 2026
…ck (obs-rust#1612)

* test: Start the output interleaver with slot 0 of the video encoders empty

obs_output_set_video_encoder2() lets a multitrack video output leave
slot 0 empty and use slot 1 or higher, and obs_output_can_begin_data_
capture() accepts that (video_valid() checks every slot). The start of
the interleaver then never runs: prune_premature_packets() and
get_interleaved_start_idx() look for the first video packet of track 0
only, find none, and the start is skipped. The next packet sees both
received flags set and is sent as if started, with no offsets applied.
The packets queued before the start keep the encoder's system-time
dts_usec, so they sort after everything sent later and stay queued
until the output stops: the first keyframe is never sent, and the
output starts on a frame that is not a keyframe with timestamps that
are not offset to 0.

test_output_interleave_e2e runs its four cases again with the video
encoder in slot 1 and slot 0 empty (the output is registered
OBS_OUTPUT_MULTI_TRACK_AV so that slot 1 can be set; the slot 0 cases
are unchanged). All four fail on master against libobs and
libobs-with-rust: the first packet is audio, then video frame 1, not
the keyframe of frame 0 at dts 0. The Tier 1 port gets the same two
start cases on its model output.

Refs obs-rust#1611

* libobs: Start the output interleaver on the first video encoder's track

The interleaver's start follows the first video packet of track 0:
prune_premature_packets() and get_interleaved_start_idx() look for it,
and with slot 0 of the video encoders empty (a multitrack video output
set up with obs_output_set_video_encoder2() and an index above 0, which
obs_output_can_begin_data_capture() accepts) they never find one. The
start was then skipped, the next packet was sent as if started, without
offsets, and the packets queued before the start (the first keyframe
among them) kept their system-time dts_usec, sorted after everything
sent later, and stayed queued until the output stopped. The output
started on a frame that is not a keyframe.

Both now follow the track of the first video encoder, as
initialize_interleaved_packets() already does
(obs_output_interleave_first_video_encoder_index()). With slot 0 set,
that is track 0, so nothing changes for those outputs. The C original
and the Rust core get the same change, so the Tier 3 parity holds; the
Rust pure functions take the track as an argument (the four Tier 1
calls pass 0).

Fixes obs-rust#1611

* docs: Fill in the PR links of the obs-rust#1509 features line

It was merged with a literal #PR placeholder. The fix landed in obs-rust#1562
(zeroed video fields) and obs-rust#1565 (no crash before obs_startup).

Refs obs-rust#1611
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

bug: util: os_generate_formatted_filename uses video info that obs_get_video_info did not fill

2 participants