Skip to content

Instantly share code, notes, and snippets.

@rondhi
Last active December 7, 2024 23:00
Show Gist options
  • Save rondhi/f9163e7649aa734b5421a8f58bd6c49e to your computer and use it in GitHub Desktop.
Save rondhi/f9163e7649aa734b5421a8f58bd6c49e to your computer and use it in GitHub Desktop.
How to stream games from OBS directly from Steam Deck's Gaming Mode

How to stream games from OBS directly from Steam Deck's Gaming Mode (as of 2023-02-26)

DISCLAIMER: As with any guide, please make sure to read through and understand everything before following the steps in this guide. I'm not responsible for you breaking anything on your own device. This guide assumes you have a little background with the linux command line as well as the text editor nano. If not, please educate yourself


Description: It's possible to stream Vulkan and OpenGL games from Gaming Mode on your Steam Deck. This guide is heavily based on robertkirkman's guide, which is linked multiple times throughout this guide. Much thanks to them


Basic summary

  1. Install OBS Studio and OBS VkCapture Plugin via flatpak
  2. Add OBS Studio to Steam
  3. Install rwfus Read-Write OverlayFS for Steam Deck
  4. Add the chaotic-aur repository
  5. Install obs-vkcapture-git via chaotic-aur
  6. Add Game Capture source to OBS
  7. Edit game launch options

In Steam Deck Desktop Mode

1. Install OBS Studio and OBS VkCapture Plugin via flatpak

  • OBS Studio
  • OBS VkCapture Plugin
  • Note: You may notice that the Discover Store also has an OBS VkCapture tools but I haven't been able to get a game capture going that way. I was only able to get a game capture by installing obs-vkcapture via command line/AUR.

According to OBS VkCapture Github

If you use Flatpak OBS, you need to install Flatpak OBS plugin. For capturing games outside Flatpak runtime, you need native build regardless of if you are using Flatpak OBS or not.

OBS-flatpak-install

2. Add OBS Studio to Steam (Source)

a. From the start menu, find OBS Studio, right-click, and add OBS Studio to Steam. I also recommend adding it to your favorites in Steam.

b. In order to get OBS Studio to launch in Gaming Mode: In Steam, edit the launch options for OBS Studio:

LD_PRELOAD= OBS_USE_EGL=1 QT_QPA_PLATFORM=xcb %command% run --branch=stable --arch=x86_64 --command=obs com.obsproject.Studio

OBS-launch-options

3. Install rwfus Read-Write OverlayFS for Steam Deck Source

These instructions may not be up-to-date. Visit the rwfus github page for up-to-date installation instructions.

The advantage of using an OverlayFS is that any packages you install via pacman or AUR will persist even after a SteamOS update. We want to use the dev branch of rwfus because it's been updated for SteamOS 3.4.

Open up the the terminal app (by default, it's Konsole on SteamOS). Keyboard shortcut is usually CTRL+ALT+T. Enter the following commands one by one.

cd ~
wget -O rwfus.zip https://github.com/ValShaped/rwfus/releases/download/v0.4.1-beta1/rwfus-0.4.1-beta1.zip && unzip rwfus.zip -d rwfus
cd rwfus
chmod +x rwfus

These commands download the latest rwfus release. Side note: if you don't have a sudo password set up, use passwd, then enter the rest of the commands to install rwfus.

sudo ./rwfus --install
sudo pacman-key --init
sudo pacman-key --populate
sudo pacman -Sy

4. Add the chaotic-aur repository

First, you should educate yourself on what the Arch User Respository (AUR) is. It's a community driven repository which is meant to help users build packages from source. It's up to the user to verify the contents of the package.

The Chaotic AUR is a repository of pre-built packages. Please see this on the safety of using Chaotic AUR and AUR in general. Is chaotic-aur safe to use?

Add the chaotic repository to your list of repository mirrors. Find up-to-date instructions here

sudo pacman-key --recv-key FBA220DFC880C036 --keyserver keyserver.ubuntu.com
sudo pacman-key --lsign-key FBA220DFC880C036
sudo pacman -U 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-keyring.pkg.tar.zst' 'https://cdn-mirror.chaotic.cx/chaotic-aur/chaotic-mirrorlist.pkg.tar.zst'

Now to add the chaotic-aur mirror to the repository list. We do this by appending some text to the end of the /etc/pacman.conf file. You can do this by editing the file with nano or vi with root access.

sudo nano /etc/pacman.conf
[chaotic-aur]
Include = /etc/pacman.d/chaotic-mirrorlist

Finally, refresh the repository list

sudo pacman -Sy

5. Install obs-vkcapture-git via chaotic-aur

sudo pacman -S obs-studio chaotic-aur/obs-vkcapture-git

After confirming, you should have obs-vkcapture installed. You can make sure you have it installed by typing

obs-vkcapture

And you should see something like

WARNING: Please use obs-gamecapture instead.
ERROR: No program supplied

Usage: obs-gamecapture <program>

7. Add Game Capture source to OBS

  • You can add a Game Capture source within OBS. Default settings are fine.
  • I suggest right-clicking the source and selecting Transform > Fit to Screen so it fits to the canvas no matter what resolution you're playing at.

add-game-capture-source

8. Edit game launch options

Once you have obs-vkcapture installed, edit a game's launch options with the line below. The Game Capture source will capture whatever game you're running with these launch options:

obs-gamecapture %command%

edit-game-launch-options

In Steam Deck Gaming Mode

  1. Press the Steam button. Go to Library. Press R1 until you get to NON-STEAM. Launch OBS Studio (you can also find it in your Favorites if you favorited it earlier in the guide)
  2. Press the Steam button. Go to Library. Launch your desired game
  3. As long as the game you choose supports OpenGL or Vulkan, OBS Studio should be able to capture that game.
  4. Have fun streaming on the go!

OBS-gaming-mode

Note: Even if the game is OpenGL or Vulkan, there's no guarantee that OBS will be able to capture the game. Your mileage may vary.

Other tips

  • If you don't want to pull from chaotic AUR all the time, you can remove the repository from pacman.conf by commenting out the lines with # and then refresh the repository list:
#[chaotic-aur]
#Include = /etc/pacman.d/chaotic-mirrorlist
  • You can use Droidcam OBS plugin to use your smartphone as a webcam source in OBS. More info here
  • Another possible smartphone-as-a-camera method is VDO Ninja
  • If you want to isolate game audio, you can use Helvum (found in Discover Store) and a Jack audio source within OBS to isolate the game sounds
  • In case you want to stream over to Discord or something, you can enable Virtual Camera in OBS

Install OBS VirtualCam (Source)

sudo pacman -S linux-neptune-headers libappindicator-gtk3
sudo pacman -S v4l2loopback-dkms v4l2loopback-utils

Support

If you need any support, feel free to post open a support post in the help channel on the Steam Deck discord and tag @rondhi#1234

@X-m7
Copy link

X-m7 commented Dec 5, 2023

The recording doesn't pause with the GStreamer method for me (both when switching back to the library view as well as when switching to games), but the colours in the capture look quite dark, like this:

20231206022550_1

@rondhi
Copy link
Author

rondhi commented Dec 7, 2023

I noticed this behavior. This didn't happen before 3.5 went stable. My workaround was to apply a color correction filter. Play around with the gamma/contrast until you get a color that works for you.

The recording doesn't pause with the GStreamer method for me (both when switching back to the library view as well as when switching to games), but the colours in the capture look quite dark, like this:

20231206022550_1

@RblSb
Copy link

RblSb commented Dec 15, 2023

About darker colors, there is another workaround without playing with filters. It's funny, but you just need to install decky recorder.
Then, before opening OBS, enable replay mode in decky recorder, open OBS, and you will get good colors in OBS preview and recordings. Decky recorder replay can be disabled after you opened OBS.

This hack works probably because they both use gstreamer and override some parameters for each other. I don't really know what exactly, and it is pain in ass to change and test complex gstreamer args for obs, but still, there's my 2 cents.

@itzzjd123
Copy link

Hey so I am trying my absolute best at implying the obs-gamecapture %command% into one of my emulator games launch options. Any idea as to how?

The games launch option is vblank_mode=0 %command% -f -g "'/home/deck/Emulation/roms/switch/Animal Crossing New Horizons [01006F8002326000] [v1835008] (1G+1U+3D).xci'"

image

@rondhi
Copy link
Author

rondhi commented Dec 20, 2023

@itzzjd123

vblank_mode=0 %command% -f -g "'/home/deck/Emulation/roms/switch/Animal Crossing New Horizons [01006F8002326000] [v1835008] (1G+1U+3D).xci'"

Should be something like

vblank_mode=0 obs-gamecapture %command% -f -g "'/home/deck/Emulation/roms/switch/Animal Crossing New Horizons [01006F8002326000] [v1835008] (1G+1U+3D).xci'"

I don't know if that will work. I haven't touched vkcapture in forever since I prefer to use the gstreamer method now.

@itzzjd123
Copy link

@rondhi it worked thanks!

@L1Z3
Copy link

L1Z3 commented Jan 2, 2024

@Kiwii Your guide for getting obs-gamecapture working without any overlays works great, thanks! But just today I noticed that it stopped working. Upon further investigation it seems that libobs_glcapture.so has moved, probably due to an update to the Flatpak. To fix this, I just modified your obs-gamecapture script so it looks in the new directory, changing

LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}${lib_path}/x86_64-linux-gnu/:${lib_path}/i386-linux-gnu/"

to

LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${LD_LIBRARY_PATH:+:}${lib_path}/x86_64-linux-gnu/:${lib_path}/i386-linux-gnu/:${lib_path}/x86_64-linux-gnu/obs_glcapture/:${lib_path}/i386-linux-gnu/obs_glcapture/"

in your script. Thanks again for the guide!

@SuDunPo
Copy link

SuDunPo commented Jan 17, 2024

Hi! but how to remove black bars on the sides on the stream?

@Frankenmint
Copy link

Hi! but how to remove black bars on the sides on the stream?

that has to do with your settings for the resolution based on the emulator and also on the obs i'd suspect. Check to see if you can set the emulator to remove the black bars but if you stretch it across the screen it may not fit the native resolution, (think nintendo game in 4:3) and will look stretched funny. I know my punchOut game for NES has horizontal black bars and im certain that they will show on the screen if I mess with it.

@Nellz42
Copy link

Nellz42 commented Mar 14, 2024

Anyone knows how to use gstreamer on deck after the obs update, mine just shows black

@SuDunPo
Copy link

SuDunPo commented Mar 16, 2024

Same Problem

@rondhi
Copy link
Author

rondhi commented Mar 18, 2024

Not really sure what the problem is. Though if you plug in a monitor to the Steam Deck, it refreshes the gstreamer source. Not really a convenient workaround.

@SuDunPo
Copy link

SuDunPo commented Mar 18, 2024

Wow, not really know how it works, but when I plug in a monitor, then in monitor settings "sic!" turn it on "Amd free sync" the image finally appeared, after I turn it off image keep true. But this settings are reset, after quit obs app.

@SuDunPo
Copy link

SuDunPo commented Mar 22, 2024

@Kiwii Your guide for getting obs-gamecapture working without any overlays works great for me too, thanks.

@SuDunPo
Copy link

SuDunPo commented Mar 27, 2024

So, why Gstreamer methode doesn't work more on SteamDeck? It's only for me, or some peoples have same problem?

@atsen-dev
Copy link

I've same problem too, last week it was working but not recently following some update...

@Cyphs
Copy link

Cyphs commented Mar 31, 2024

I was able to get it working by downgrading the OBS version to 30.0.2.

To downgrade, make sure OBS Studio is installed like normal, then open the terminal (Konsole) and enter:

sudo flatpak update --commit=e641d66f8f509ff18c1e82bfd6e32e0e0021e56cb01d1471b00f56d82ea8bfa1 com.obsproject.Studio

If you need to install GStreamer, enter:

flatpak install com.obsproject.Studio.Plugin.Gstreamer

Should be good for now until a fix for newer versions are found. Just don't update it in the Discover app.

Actually, I only tried 30.0.2 because of a YouTube video, so unsure exactly what update broke it. If you want to get the commits for other previous versions, type: flatpak remote-info --log flathub com.obsproject.Studio
Then compare it to the release dates on GitHub or wherever.

@rondhi
Copy link
Author

rondhi commented Mar 31, 2024

@Cyphs thanks for this information! I was leaning towards the issue being caused by OBS 30.1, so this kinda confirms it.

@SuDunPo
Copy link

SuDunPo commented Apr 2, 2024

@Cyphs thanks dude!

@LTJ233
Copy link

LTJ233 commented Jul 13, 2024

I haven't updated my guide in a while, but I currently recommend Kiwii's gstreamer method here. You can do all this without having to touch the terminal.

  1. Install OBS and OBS Gstreamer Plugin from the Discover store (this store is also known as flatpak).
  2. To make OBS launchable from Gaming Mode: add OBS to Steam and edit the launch options:
LD_PRELOAD= OBS_USE_EGL=1 QT_QPA_PLATFORM=xcb %command% run --branch=stable --arch=x86_64 --command=obs com.obsproject.Studio
  1. Open OBS and add a Gstreamer source into OBS and replace the example pipeline with:
pipewiresrc do-timestamp=True ! queue max-size-buffers=100 max-size-time=1000000000 ! video.
  1. Make the source fit to screen so it'll display no matter the resolution of the game. Right-click your newly-created Gstreamer source > Transform > Fit to screen
  2. Add an Output Output Capture to capture the audio from the Steam Deck. See Kiwii's instructions if you wanna specifically capture game audio

@Kiwii @rondhi
After installing the above flatpaks, I can't find the GStreamer source in OBS, why is that?

@X-m7
Copy link

X-m7 commented Jul 13, 2024

OBS recently updated to version 30.2, which seems to have broken both the GStreamer and Vulkan/game capture plugins completely at the moment, so you'll need to install an older version instead, I think one of the previous comments has a command for that.

@LTJ233
Copy link

LTJ233 commented Jul 13, 2024

OBS recently updated to version 30.2, which seems to have broken both the GStreamer and Vulkan/game capture plugins completely at the moment, so you'll need to install an older version instead, I think one of the previous comments has a command for that.

@X-m7 Thx bro! It works pretty good after degrading.It seems that 30.0.2 should be the most compatible solution for now.

@SuDunPo
Copy link

SuDunPo commented Jul 14, 2024

As I wrote above I'm using the version 30.1.2 because in version 30.0.2 we can't choose VAAPI H.264 on VanGogh [AMD Custom GPU 0405] as Video Encoder. If you like me use Lutris for running non-steam games & want to stream them using "Game Capture" methode, move "obs-gamecapture.sh" script from /home/deck/.local/bin to your's wine-prefixes directory, in my case it's /home/deck/.wine .
And then add line /home/deck/.wine/obs-gamecapture %command% in Launch parameters of your non-steam game in Steam Library.

I didn't change anything in the obs-gamecapture script itself. Works good.

Update: I don't know why, but it's not work with lutris-flatpak. =/

@darylducharme
Copy link

Does anyone know if 30.2.0 has fixed this so we can update and still use the Gstreamer method?

@CoderMonkey1956
Copy link

CoderMonkey1956 commented Jul 17, 2024

Does anyone know if 30.2.0 has fixed this so we can update and still use the Gstreamer method?

Unfortunately, for now you have to run this command to downgrade obs: sudo flatpak update --commit=e641d66f8f509ff18c1e82bfd6e32e0e0021e56cb01d1471b00f56d82ea8bfa1 com.obsproject.Studio (Thanks @Cyphs)

@LTJ233
Copy link

LTJ233 commented Jul 17, 2024

I would like to ask why try to use the latest version since 30.0.2 is available? Does it have better performance?🤔

@rondhi
Copy link
Author

rondhi commented Aug 3, 2024

obs-gstreamer was recently updated. I did try using it on OBS 30.2, but it's still unable to get an image from gamescope. So my recommendation is to still stay on OBS Studio 30.0.2 for capturing games in Game Mode with obs-gstreamer. I haven't done any research on why it stopped working on OBS 30.1+, and I'm not knowledgable enough to figure out why. I hope others will be able to figure out what's going on.

@Urfoex
Copy link

Urfoex commented Oct 24, 2024

OBS 30.2.3
SteamOS 3.6.19 Stable
It seems to work again.

Step 3 says rwfus
They recommend nix, so I tried
$ sh <(curl -L https://nixos.org/nix/install) --no-daemon

$ sudo chown -R deck /nix
$ rm ~/.local/state/nix/
$ sh <(curl -L https://nixos.org/nix/install) --no-daemon
$ source /home/deck/.nix-profile/etc/profile.d/nix.sh 

And then inside the Steam Game Properties:

nix-shell -p obs-studio-plugins.obs-vkcapture --run "obs-gamecapture %command%"

This didn't want to work inside steam.
I found https://search.nixos.org/packages?channel=24.05&show=obs-studio-plugins.obs-vkcapture&from=0&size=50&sort=relevance&type=packages&query=vkcapture

nix-env -iA nixos.obs-studio-plugins.obs-vkcapture

And then you can use obs-gamecapture as usual. But games still didn't work for me.

obs-gamecapture %command%

With a local version of https://anuke.itch.io/mindustry it worked.

So I used rwfus and it worked again.

@rondhi
Copy link
Author

rondhi commented Nov 10, 2024

OBS 30.2.3
SteamOS 3.6.19 Stable
It seems to work again.

I'd also like to point out that Flatpak OBS 30.2.3 on SteamOS 3.6.20 is also working again with the gstreamer (flatpak) method, which is still my recommended method, explained here: https://gist.github.com/rondhi/f9163e7649aa734b5421a8f58bd6c49e?permalink_comment_id=4653330#gistcomment-4653330

@SuDunPo
Copy link

SuDunPo commented Nov 11, 2024

Congratulations.

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