Repository navigation
libobs: Report no video from obs_get_video_info before obs_startup - #1565
Merged
zackees merged 3 commits intoOct 20, 2026
Merged
Conversation
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
…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
enabled auto-merge
October 20, 2026 22:12
4 of 5 tasks
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
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.
Fixes #1509 (with #1562, which fixed the uninitialized fields; this is the crash before
obs_startup)What and why
obs_get_video_infonow returnsfalsebeforeobs_startup, soos_generate_formatted_filenameformats a name normally there. Before,obs_get_video_infodereferenced 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.!obs ||inobs_get_video_info(libobs/obs.c.h), the wayobs_reset_videoandobs_reset_audioguard the core next to it.falseis 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,%ORESand%VFas0,0x0,0x0andNone. No other getter changes.test_formatted_filenameand the Tier 3 parity test pin, and a format with a video specifier would still crash.obs-util::platform_filename'sos_generate_formatted_filenamecalls the same Cobs_get_video_info(there is no Rust port of it), so the fix covers both libraries. Its# Safetynote no longer says libobs must be started.docs/features.mdline 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'splatform-filenamerow still says "Beforeobs_startupboth crash inobs_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):
test_platformwith the RED test, both lanes, againstlibobsandlibobs-with-rusttest_formatted_filename_before_startupfails (child killed by signal 11), 30/31 passtest_platform, both lanes, both librariestest_audio_controls, C lane againstlibobs, unrelated; 5/5 on rerun)RED → GREEN
test: Format a file name before obs_startup. A new case intest_platform(it links the real libobs;test_formatted_filenamereplacesobs_get_video_infowith a fixture) callsobs_get_video_infoandos_generate_formatted_filename("mkv", true, "before startup")beforeobs_startup, in a child process, and expectsfalseand"before startup.mkv". On master the child dies with SIGSEGV, sotest_platformfails 1 of 31, in the C lane (ENABLE_RUST_LIBOBS=OFF) and the libobs-with-rust lane (ON), each against bothlibobsandlibobs-with-rust.test_platform31/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 againstlibobs, had atest_audio_controlssetup failure, an audio-only test that does not call this code, which passed 5/5 on rerun). After the rebase,test_platform,test_formatted_filenameandtest_audio_controlspass 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.Checklist
masterdocs/features.mdis 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)-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)