Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] An option to prepend a command #530

Closed
Nano-Ocelot opened this issue Aug 2, 2022 · 26 comments
Closed

[FEATURE] An option to prepend a command #530

Nano-Ocelot opened this issue Aug 2, 2022 · 26 comments

Comments

@Nano-Ocelot
Copy link
Collaborator

It would be nice to have the ability to place a command in front of the game command in the same way that you can in steam launch options like, 'examplecommand' %command%. Specifically what I want to do is run the game like this obs-vkcapture %command% to start the game with obs-vkcapture capturing the game window and sending it to OBS. Maybe there already is an option like this but I can't seem to find it and I've been reading through the wiki and experimenting with options for hours.

@frostworx
Copy link
Collaborator

parsing commands prepended in the steam launch option is no option, but I consider adding obs-vkcapture support.

@Nano-Ocelot
Copy link
Collaborator Author

Excellent. It's a great tool to easily capture a game window for recording and streaming. It works on Wayland and X11 and is probably the most performant of all methods I've ever used. That would be a great feature.

Here's the link to it.
https://github.com/nowrep/obs-vkcapture

@frostworx
Copy link
Collaborator

Thanks for the link. In fact I already started with the implementation yesterday. :)
I might have soon something to test, but it is not fully functional yet and there are some other issues open which I like to finish before.

@Nano-Ocelot
Copy link
Collaborator Author

I'll be a guinea pig if you need any testing. Just let me know when it's ready to test.

frostworx pushed a commit that referenced this issue Aug 2, 2022
… starting the game #523 and added an option to start the game through obs-vkcapture #530 (WIP)
@frostworx
Copy link
Collaborator

The above push contains the initial code for using obs-vkcapture directly when launching a game.
The function can be enabled per game with the USEOBSVKC option.
I haven't really tested very much yet, but it doesn't seem to do anything useful for now. Will hopefully keep on working on it soon :)
Would be great if you would test (maybe too early in the current state, but maybe you find something out already).
It would be amazing, if you'd even add a little wiki when the function is implemented functionally :)

@frostworx
Copy link
Collaborator

frostworx commented Aug 2, 2022

heh, just tested it (with Bubble Bobble 4) and it just works :)

Maybe a good idea to automatically start obs (directly with OBS_USE_EGL=1 obs)
when it is not already running. What do you think?

@Nano-Ocelot
Copy link
Collaborator Author

That's not a bad idea to just do it automatically. I was just going to add that to my 'game-start-script.' If you're going to do that it might be best to also run it like OBS_USE_EGL=1 obs --minimize-to-tray.

Or maybe it's better to leave that all up to the user? Some people might also want it to start with replay buffer automatically at start. Or go straight to streaming or recording. For instance my personal plan is to start with replay buffer because I'm using it as a more performant version of replaysorcery or nvidia shadowplay.

@frostworx
Copy link
Collaborator

Last time I used obs was for "playing PS4" games on my linux desktop using a "Blackmagic Design Intensity Pro 4K".
No idea what I configured back then exactly, but an automatic minimize-to-tray was one of the options.

Using obs command line arguments is generally a good idea, but as I do not really want to hardcode them I consider adding proper, standalone obs support with configuration options and just enable that "USEOBS" flag automatically, when "USEOBSVKC" is enabled.

@Nano-Ocelot
Copy link
Collaborator Author

Nano-Ocelot commented Aug 2, 2022

I can definitely test it later this week and write up a wiki for it.

As for just letting OBS config decide those things, that's a better idea but I'm not sure it has an option for auto-starting a recording or stream and that could be a problem for some people. For instance if I wanted to just start up OBS with the game and immediately start a replaybuffer or stream then the best option I could have is to either put the command in my game-start-script and deal with two instances of OBS running or close the other instance manually every time which defeats the purpose of automating it all. Perhaps if you do decide to auto-start OBS then make it a separate nested toggle just below USEOBSVKC or even an entirely separate toggle altogether? I bet some people would like to use only the USEOBS option for their own setups.

@frostworx
Copy link
Collaborator

True, obs autostart should be optional in every case.
Thanks for willing to write the wiki and testing 👍

@Nano-Ocelot
Copy link
Collaborator Author

I did a brief test and it worked perfectly first try! 😄

@zany130
Copy link
Collaborator

zany130 commented Aug 3, 2022

Sorry that I haven't been active here lately been busy. Was actually going to suggest vkcapture and try my hand at a PR but guess you guys beat me to it lol.
Works like a charm here, however in regarding to this

Maybe a good idea to automatically start obs (directly with OBS_USE_EGL=1 obs) when it is not already running. What do you think?

Not sure about starting obs with EGL automatically this is not needed on Wayland and IDK if it can cause issues there

@frostworx
Copy link
Collaborator

wb and thx for testing :)
Hm, good point.
Maybe better leave it up to the user if and how obs is started then generally. Saves the time for the implementation and apparently might cause more issues (to debug) than its worth.

@frostworx
Copy link
Collaborator

the implementation seems to work fine. please ping me when you're read to add a corresponding wiki @Nano-Ocelot and I'll will send you a wiki editor invite.

@Nano-Ocelot
Copy link
Collaborator Author

Will do. I also had another thought. It's not going to be used as much as USEOBSVKC but what about another option for opengl games that uses the command obs-glcapture game?

@frostworx
Copy link
Collaborator

frostworx commented Aug 7, 2022

already sent you the invite earlier today (edit: ah I see you already accepted - nice :))
for obs-glcapture game please see #535 and #537
patches always still welcome of course

@Nano-Ocelot
Copy link
Collaborator Author

Oh, I see! Thanks for all your hard work anyway. Maybe one day I can sit down when I have the time to learn how and implement the feature myself. 👍

@frostworx
Copy link
Collaborator

no hurry, but it should be more or less a copy/paste of the obs-vkcapture part of above commit

@zany130
Copy link
Collaborator

zany130 commented Aug 14, 2022

noticed an issue with the obs-vkcapture it sometimes (don't know why) gets added to the game's launch command before gamescope. Doing this causes gamescope to crash as can be seen by trying the following in a terminal

obs-vkcapture gamescope vkcube
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
wlserver: [backend/headless/backend.c:82] Creating headless backend
[obs-vkcapture] Init Vulkan 1.1.5
vulkan: selecting physical device 'AMD RADV NAVY_FLOUNDER': queue family 1
vulkan: physical device supports DRM format modifiers
[obs-vkcapture] Injecting VK_KHR_bind_memory2 extension
[obs-vkcapture] Injecting VK_KHR_get_memory_requirements2 extension
vulkan: supported DRM formats for sampling usage:
vulkan:   0x34325241
vulkan:   0x34325258
vulkan:   0x3231564E
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X0: Address already in use
wlserver: [xwayland/server.c:92] Starting Xwayland on :2
wlserver: [types/wlr_surface.c:741] New wlr_surface 0x560f31dec820 (res 0x560f31d9a7e0)
wlserver: [xwayland/server.c:250] Xserver is ready
[obs-vkcapture] Init Vulkan 1.1.5
Selected GPU 0: AMD RADV NAVY_FLOUNDER, type: DiscreteGpu
wlserver: [types/wlr_surface.c:741] New wlr_surface 0x560f31dd41f0 (res 0x560f31d8da60)
[obs-vkcapture] Injecting VK_KHR_bind_memory2 extension
[obs-vkcapture] Injecting VK_KHR_get_memory_requirements2 extension
[obs-vkcapture] Injecting VK_KHR_external_memory_fd extension
[obs-vkcapture] Injecting VK_EXT_image_drm_format_modifier extension
[obs-vkcapture] Texture VK_FORMAT_B8G8R8A8_UNORM 1536x864
[obs-vkcapture] ------------------ vulkan capture started ------------------
(EE) failed to read Wayland events: Connection reset by peer
fish: Job 1, 'obs-vkcapture gamescope vkcube' terminated by signal SIGSEGV (Address boundary error)

VS

gamescope obs-vkcapture vkcube
No CAP_SYS_NICE, falling back to regular-priority compute and threads.
Performance will be affected.
wlserver: [backend/headless/backend.c:82] Creating headless backend
vulkan: selecting physical device 'AMD RADV NAVY_FLOUNDER': queue family 1
vulkan: physical device supports DRM format modifiers
vulkan: supported DRM formats for sampling usage:
vulkan:   0x34325241
vulkan:   0x34325258
vulkan:   0x3231564E
wlserver: Running compositor on wayland display 'gamescope-0'
wlserver: [backend/headless/backend.c:18] Starting headless backend
wlserver: [xwayland/sockets.c:63] Failed to bind socket @/tmp/.X11-unix/X0: Address already in use
wlserver: [xwayland/server.c:92] Starting Xwayland on :2
wlserver: [types/wlr_surface.c:741] New wlr_surface 0x563a8a9337c0 (res 0x563a8a7a2b60)
wlserver: [xwayland/server.c:250] Xserver is ready
[obs-vkcapture] Init Vulkan 1.1.5
Selected GPU 0: AMD RADV NAVY_FLOUNDER, type: DiscreteGpu
wlserver: [types/wlr_surface.c:741] New wlr_surface 0x563a8a91a3b0 (res 0x563a8a91d550)
[obs-vkcapture] Injecting VK_KHR_bind_memory2 extension
[obs-vkcapture] Injecting VK_KHR_get_memory_requirements2 extension
[obs-vkcapture] Injecting VK_KHR_external_memory_fd extension
[obs-vkcapture] Injecting VK_EXT_image_drm_format_modifier extension
[obs-vkcapture] Texture VK_FORMAT_B8G8R8A8_UNORM 500x500
[obs-vkcapture] ------------------ vulkan capture started ------------------
The XKEYBOARD keymap compiler (xkbcomp) reports:
> Warning:          Unsupported maximum keycode 708, clipping.
>                   X11 cannot support keycodes above 255.
Errors from xkbcomp are not fatal to the X server

so the gamescope command always needs to go before obs-vkcapture

@zany130
Copy link
Collaborator

zany130 commented Aug 15, 2022

image
found an interesting trick to fix the issue and also add custom launch commands to gamescope

you can replace obs-vkcapture with whatever launch command you want

@frostworx
Copy link
Collaborator

good find. leaving this issue open, maybe someone is interested to send a fix.

@sonic2kk
Copy link
Owner

I wonder if #560 will have any impact on this?

@zany130
Copy link
Collaborator

zany130 commented Aug 29, 2022

I wonder if #560 will have any impact on this?

for some reason it seems to fix it 🤷 checked the start debug logs and it seems steamtinkerlaunch is now adding obs-vkcapture before gamescope

also as @Nano-Ocelot also wanted OpenGL capture I tried replacing obs-vkcapture with obs-gamecapture which automatically selects the correct one depending if the game is OpenGL or Vulkan seems to work here I'll post a PR shortly

@sonic2kk
Copy link
Owner

Woohoo! Once your PR is merged maybe we can close this issue? I believe prepending should work, the argument order for gamescope seems to be resolved, and the obs-gamecapture PR should resolve the other part of this issue about implementing capture for OpenGL.

@zany130
Copy link
Collaborator

zany130 commented Aug 30, 2022

yeah agree the original issue was for the ability to add a custom command but that can be done with https://github.com/frostworx/steamtinkerlaunch/wiki/ENV-Variables or by adding it after the -- in gamescope as I found and documented in the game scope wiki.

@Nano-Ocelot Specificlly wanted https://github.com/nowrep/obs-vkcapture and its OpenGL counterpart which this PR should add. I need to find an OpenGL game to test with but it should just work. (I guess I can use wine3d for this but I feel like i remember seeing a check for when a game is not using proton in the code and then disables obs-vkcapture) @frostworx ?

EDIT: yup here https://github.com/frostworx/steamtinkerlaunch/blob/de990bcf54c07780ac275d1d9558c1b45274b8ec/steamtinkerlaunch#L16684

EDIT2: nvm I think what the above does is disable obs-gamecapture if you using pure wine not if your using wineD3D to convert DirectX to OpenGL I commented those lines out anyway and ran witcher enhanced edition with WINED3D and obs-gamecapture set and it worked flawlessly. Same with DXVK (thus vulkan)

@zany130
Copy link
Collaborator

zany130 commented Aug 30, 2022

I think this can be closed now, like I said above you can add env-variables per game or globaly.

You can also add a custom program to the gamescope launch options.

and OpenGL and Vulkan gamecapture for OBS should now be working with the PR linked above which has already been merged.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants