Skip to content

obs-outputs: Fix path normalization logic#13206

Open
grimfoss wants to merge 2 commits intoobsproject:masterfrom
grimfoss:fix-directory-format-normalization-logic-error
Open

obs-outputs: Fix path normalization logic#13206
grimfoss wants to merge 2 commits intoobsproject:masterfrom
grimfoss:fix-directory-format-normalization-logic-error

Conversation

@grimfoss
Copy link

@grimfoss grimfoss commented Mar 10, 2026

Description

Changed order of operations in generate_filename() in both mp4-output.c and obs-ffmpeg-mux.c so that the full file path gets normalized to use forward slashes, instead of just the directory.

Motivation and Context

In the event that the user provides a formatting string with windows-style directories (%MM\%DD\%hh-%mm-%ss), encoding would either fail to open a new file or crash entirely if the file would be split after the date changes, due to the logic for making a new directory during file splitting only looking for the last forward slash.

How Has This Been Tested?

To test, I set automatic file splitting to 1 minute, and made the formatting string "%ss\%mm" so every split was guaranteed to make a new directory. Running a recording for one minute in each format no longer resulted in a crash or failure at the split, and a new directory being created was successfully observed in each test.

Testing environment:
Windows 11 Home 10.0.26200
AMD Ryzen 9 7900x Processor
Nvidia RTX 5070 Gpu
32GB GDDR5 Memory

Testing was done manually, and I do not expect these changes to affect any other areas.

Types of changes

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

Tweak (non-breaking change to improve existing functionality)

Checklist:

  • My code has been run through clang-format.
  • I have read the contributing document.
  • My code is not on the master branch.
  • The code has been tested.
  • All commit messages are properly formatted and commits squashed where appropriate.
  • I have included updates to all appropriate documentation.

@Warchamp7 Warchamp7 added the Bug Fix Non-breaking change which fixes an issue label Mar 10, 2026
@grimfoss
Copy link
Author

Background if there are issues: I'm a CS student who's only taken some intro classes so far, I ran into this issue and tracked down the cause pretty quickly and wanted to try my hand at fixing it. I'm not incredibly familiar with git but I believe I followed everything to a tee. Never contributed to anything before so any feedback on any part of this would be greatly appreciated!

@grimfoss grimfoss force-pushed the fix-directory-format-normalization-logic-error branch from bba57aa to 10b8036 Compare March 10, 2026 22:57
@grimfoss
Copy link
Author

Updated my commit message to match standards

@jcm93
Copy link
Contributor

jcm93 commented Mar 11, 2026

On macOS and POSIX-like platforms, \ is an allowed character in ordinary filenames. So it may not be correct for OBS to always interpret a backslash as a path separator in this field.

@grimfoss
Copy link
Author

On macOS and POSIX-like platforms, \ is an allowed character in ordinary filenames. So it may not be correct for OBS to always interpret a backslash as a path separator in this field.

I updated it so the original logic is restored, and the new logic is only applied to windows builds. Not sure if this is the preferred method to handle platform differences though.

Updated path normalization logic to only be applied to windows builds to prevent unintended behavior on mac and posix systems.
@grimfoss grimfoss force-pushed the fix-directory-format-normalization-logic-error branch from 79acc56 to 8f30bcf Compare March 11, 2026 18:17
@grimfoss
Copy link
Author

Considering OBS seems to always normalize directories to use forward slashes internally, and this logic is repeated in mp4-output and obs-ffmpeg-mux, and possibly other places - is a possibly better solution to add a platform specific utiity to libobs to handle directory normalization across the whole program?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Fix Non-breaking change which fixes an issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants