Repository navigation
Fix loading and crashes on OBS 30+ (drop FFmpeg dependency) - #53
Open
Mike-iLeech wants to merge 3 commits into
Open
Mike-iLeech wants to merge 3 commits into
Mike-iLeech wants to merge 3 commits into
Conversation
The 1.5.2 release links avcodec-59.dll/avutil-57.dll, which only ship with OBS 28. On newer OBS the DLL fails to load and the filter silently disappears from the filter list (synap5e#48, synap5e#52). - Encode PNG with the bundled stb_image_write.h instead of FFmpeg, so the plugin no longer depends on the FFmpeg version shipped with OBS. - Fix crash when the source reports 0x0 (e.g. a media source restarting): OBS 30+ aborts on bmalloc(0). - Fix heap overflow when the staging surface row pitch exceeds width * 4 + 128 (odd widths such as 853x480): copy rows into a tightly packed buffer, linesize is now width * 4. - Write named shared memory under the mutex so a resize cannot unmap or shrink it mid-copy; check the frame fits the mapping. - Create the mutex before starting the writer thread, close the thread handle on destroy, handle create() failure and NULL data in filter_remove. - Fix aliasing snprintf when building HTTP headers, shmem header size (16 bytes, not 12), wide shmem name conversion. - Remove FFmpeg and w32-pthreads from the CMake build; bump to 1.6.0. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- destroy now waits for the writer thread to exit instead of giving up after 5 s and freeing the filter while it may still be encoding or uploading; WinINet connect/send/receive timeouts (5 s) bound how long an unreachable server can block it. - Take the graphics context before the filter mutex in tick and destroy, matching render, to avoid a lock-order deadlock when another thread renders the source (e.g. obs-websocket screenshots). - Keep a private copy of the destination string; the settings string can be freed when the user edits properties while the writer uses it. - Folder output: fix overlapping snprintf and "_1.raw.png" names on retries (now "_1.png"), check localtime() result. - Use the CRT allocator for stb so an allocation failure while encoding does not abort OBS. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- Only register the capture hotkey while the filter has a parent, and unregister it in destroy, so a hotkey can't fire on a freed filter. - Open files with os_fopen: OBS passes UTF-8 paths and fopen expects the ANSI code page, so non-ASCII folders (e.g. Cyrillic) failed. - Allocate the frame buffer only when the staging surface was created and compute its size in size_t (sources above 16384 px). - Terminate the shared memory name, limit WinINet connect retries to 1 (connect timeout is per attempt), User-Agent 1.6.0. - Route stb allocations back through bmalloc: stb does not handle a failed realloc in release builds, a clean OBS abort is better than heap corruption. (Corrects the previous commit.) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Makes the plugin load and run on OBS Studio 30, 31 and 32.
Fixes #52, fixes #48 (also relevant to #42, #45).
Root cause
The 1.5.2 release links
avcodec-59.dll/avutil-57.dll, which only ship with OBS 28. Every newer OBS ships different FFmpeg DLL names, so the plugin DLL fails to load and the filter silently disappears from the filter list. FFmpeg was only used to encode PNG, so this PR replaces it with the single-header, public-domainstb_image_write.h— the plugin now has no dependency on OBS's FFmpeg at all (the DLL imports onlyobs.dll,wininetand the system CRT).Crash fixes
Once loading worked, a few crashes showed up on current OBS (one of them hit in real use, crash report:
bmalloc←screenshot_filter_tick):bmalloc(0).Smaller fixes
os_fopeninstead offopenso non-ASCII (e.g. Cyrillic) paths work._1.raw.pngnames; overlappingsnprintffixed (also in the HTTP headers).mbstowcsoverflow of the shmem name.Behaviour change
Raw output and shared memory frames are now tightly packed (
linesize = width * 4) instead of carrying the driver's row pitch. Shared memory consumers that honour thelinesizeheader field are unaffected; raw file/HTTP consumers never received the pitch, so this makes the data predictable.Build / testing
CMakeLists.txtno longer needs FFmpeg or w32-pthreads; version bumped to 1.6.0.buildspec.jsonstill builds against OBS 29.1.2 headers, which is fine since the plugin API used is unchanged.obs.dllof OBS 31.0.4 and 32.2.2 (filter registers, defaults and properties OK), PNG output verified pixel-by-pixel with a padded stride, folder naming incl. a Cyrillic path; an earlier build of this branch (loading + 0x0 crash fix) was used on OBS 31.0.4 with a media source.🤖 Generated with Claude Code