Skip to content

frontend: Sanitise Advanced mode recording filenames - #200

Merged
zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/199-recording-filename-sanitise
Oct 11, 2026
Merged

zackees merged 2 commits into
obs-rust:masterfrom
rdoupe:fix/199-recording-filename-sanitise

Conversation

@rdoupe

@rdoupe rdoupe commented Oct 11, 2026

Copy link
Copy Markdown
Collaborator

Description

In Advanced output mode, recordings kept characters such as : from the filename format in their names. With %CCYY-%MM-%DD %hh:%mm:%ss a recording was saved as 2026-10-11 01:14:55.mkv, while a saved replay buffer, a Simple mode recording or a screenshot with the same format had the : replaced. With this change Advanced mode recordings, and their split files, are sanitised the same way.

AdvancedOutput::StartRecording() passed the raw FilenameFormatting setting to GetRecordingFilename() and to the split-file format setting. Every other file output (replay buffer in both modes, Simple mode recording, screenshots, the multitrack stream dump) first runs it through GetFormatString(), which replaces * ? " | : > < with _ and \ with /. libobs's os_generate_formatted_filename() does not sanitise, so the split files got the raw format too.

  1. test: Fail the recording filename format against a stub (upstream #13786): adds output_filename_format() in frontend/utility/output-filename-format.c, a Qt-free form of GetFormatString() that the test builds directly, and test_output_filename_format. The stub returns the format unchanged, as the Advanced recording path did, so 5 of its 6 tests fail on this commit:
    • test_recording_format_replaces_colons
    • test_replay_buffer_format_replaces_colons
    • test_recording_matches_replay_buffer
    • test_every_reserved_character_is_replaced
    • test_subdirectories_in_format_are_kept
    • test_plain_formats_are_unchanged passes: a format without reserved characters is left alone.
  2. frontend: Sanitise Advanced mode recording filenames (upstream #13786): moves the GetFormatString() logic into output_filename_format() and makes GetFormatString() wrap it, so all callers share one implementation. AdvancedOutput::StartRecording() now uses GetFormatString(filenameFormat, nullptr, nullptr) for both the first file and the split-file format. Only the format changes. The recording directory is never touched, and subdirectories in the format are kept. All 6 tests pass.

Motivation and Context

Fixes #199 (upstream obsproject/obs-studio#13786, reported by pricklythorn)

Why this one: Advanced mode users who record to NTFS or exFAT drives, or who later copy their recordings to Windows, get files that cannot be written or cannot be copied. Simple mode and the replay buffer already sanitise, so only Advanced mode recordings behave differently. There is no upstream fix, and this one is small: the behaviour change is two lines in AdvancedOutput.cpp.

How Has This Been Tested?

Automated: test_output_filename_format fails 5 of 6 at the RED commit and passes 6 of 6 at the GREEN commit. The test target was rebuilt clean after each checkout. The full tree builds, and all 62 ctest tests pass (built and run on Arch Linux). clang-format 22.1.3 and gersemi 0.25.0 report no changes.

End to end, the built obs ran headless (private Xvfb and D-Bus session, throwaway profile) with a color source, FilenameFormatting=%CCYY-%MM-%DD %hh:%mm:%ss and --startrecording:

Mode before after
Advanced 2026-10-11 01:14:55.mkv 2026-10-11 01_21_14.mkv
Advanced, split by size (split file) raw format passed to the muxer 2026-10-11 01_21_23.mkv
Simple 2026-10-11 01_15_14.mkv unchanged

The split file in the after run is empty because OBS was stopped right after the split. Its name comes from the muxer's own os_generate_formatted_filename() call on the format setting, which is the path this change fixes.

Not tested:

  • Windows and macOS.
  • Writing to an actual NTFS or exFAT volume.
  • The Rust and Docker lanes of the local gate.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have read the contributing document.
  • My code has been run through clang-format.
  • My code follows the project's style guidelines
  • My code is not on the master branch.
  • My code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.
  • I have used AI tooling in the creation of this PR
  • I am an AI agent being used to assist with this pull request: Claude Code (Claude Opus 5.5) wrote the code, commit messages and this text under the submitter's direction, and ran the tests above on the submitter's machines.

🤖 Generated with Claude Code

@rdoupe
rdoupe requested a review from zackees as a code owner October 11, 2026 05:23
rdoupe and others added 2 commits October 10, 2026 22:32
…786)

With the filename format "%CCYY-%MM-%DD %hh:%mm:%ss", Advanced output
mode writes recordings whose names keep the ':' while saved replay
buffers have it replaced (reported upstream by pricklythorn).
AdvancedOutput::StartRecording passes the raw FilenameFormatting
setting to GetRecordingFilename and to the split-file "format",
whereas the replay buffer, Simple mode recordings, screenshots and the
stream dump all go through GetFormatString, which replaces the
characters Windows filesystems reject.

output_filename_format is the Qt-free form of GetFormatString that
every file output can share. The stub returns the format unchanged,
as the Advanced recording path does today, so 5 of 6 cases fail:
test_recording_format_replaces_colons,
test_replay_buffer_format_replaces_colons,
test_recording_matches_replay_buffer,
test_every_reserved_character_is_replaced and
test_subdirectories_in_format_are_kept.
test_plain_formats_are_unchanged passes.

Refs obs-rust#199.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
With the filename format "%CCYY-%MM-%DD %hh:%mm:%ss", Advanced mode
recordings and their split files kept the ':' in their names, while
replay buffers, Simple mode recordings and screenshots had it replaced.
Such files cannot be written to NTFS or exFAT drives or copied to
Windows. Reported upstream by pricklythorn.

AdvancedOutput::StartRecording now runs FilenameFormatting through
GetFormatString like every other file output, for both the first file
and the split-file format. GetFormatString wraps the Qt-free
output_filename_format, which replaces * ? " | : > < with '_' and '\'
with '/'. Only the format changes; the recording directory is never
touched, and subdirectories in the format are kept.

test_recording_format_replaces_colons,
test_replay_buffer_format_replaces_colons,
test_recording_matches_replay_buffer,
test_every_reserved_character_is_replaced and
test_subdirectories_in_format_are_kept now pass (6/6).

Fixes obs-rust#199.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
Local-Gate: v1 tree=08724963159cdb2db00f9106c07dba15482a87ec secs=77 lanes=lint:run,rust-test:run,tier2-linux:run
Ci-Attestation: {"at":1791696801,"gate":"rust/all/fmt","host":"linux-x86_64","key":"292e234cedff0cea4b95cfac7aa0c24e8ae4ca5f6c2bf61da3d7f372499bf607","lane":"lint","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":11,"stamp":"446fc02f499915554183864c0c951b0d","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Ci-Attestation: {"at":1791696801,"gate":"rust/x86_64-unknown-linux-gnu/clippy","host":"linux-x86_64","key":"292e234cedff0cea4b95cfac7aa0c24e8ae4ca5f6c2bf61da3d7f372499bf607","lane":"lint","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":11,"stamp":"1ac26b469b145e89d34de8389f52ac56","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Ci-Attestation: {"at":1791696801,"gate":"rust/x86_64-unknown-linux-gnu/test","host":"linux-x86_64","key":"90fdd482a5db00d3ed788a4b3bb023a40268364e1dddc39c864abb334f73af4b","lane":"rust-test","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":24,"stamp":"9a2c750c1df915f8ec67bf7884b22b94","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
Ci-Attestation: {"at":1791696801,"gate":"cpp/linux-x64/tier2","host":"linux-x86_64","key":"882ab4885f23cdf6b47a7eb460314ae6747179d6648a6c1dc6b80379776615ff","lane":"tier2-linux","parents":["c558db2ae20dc6c8f290cea5b0eea3efc19fde45"],"secs":43,"stamp":"46a7afd1fffc58fd6dd7c0b12d865bbe","tree":"08724963159cdb2db00f9106c07dba15482a87ec","v":1,"via":"run"}
@zackees

zackees commented Oct 11, 2026

Copy link
Copy Markdown
Member

Verified locally, rebased onto master and stamped. The new head is 971d4f551.

  • RED (707dad6c4): Tier 2 passed 61 of 62. test_output_filename_format failed 5 tests against the stub.
  • GREEN (215b2ea03): Tier 2 passed 62 of 62 with ENABLE_RUST_LIBOBS OFF and 62 of 62 with it ON.
  • output_filename_format() matches the removed C++ GetFormatString: the prefix goes after the last / or \\, the spacing rules are the same, and reserved characters are replaced across the whole string.
  • Local gate: lint, rust-test and tier2-linux all passed.

Merging once CI is green, which includes the frontend build.

@zackees
zackees force-pushed the fix/199-recording-filename-sanitise branch from 215b2ea to 971d4f5 Compare October 11, 2026 05:33
@zackees
zackees merged commit 22f4696 into obs-rust:master Oct 11, 2026
23 checks passed
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: frontend: Advanced-mode recording filenames are not sanitised (upstream #13786)

2 participants