Skip to content

Instantly share code, notes, and snippets.

@rondhi
Last active April 12, 2024 08:23
Show Gist options
  • Star 18 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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

@rondhi
Copy link
Author

rondhi commented Aug 7, 2023

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

@csc-chicken
Copy link

Such a damn good explaination @rondhi .GStreamer is really great. I have one improvement to tell you. maybe use the gstreamer VA-API plugin is better.

@carpeggios
Copy link

carpeggios commented Nov 28, 2023

I've followed the instruction and got OBS to capture video in Gaming Mode, but only of the OBS program itself. The OBS hangs the recording as soon as I press Steam button, and swap process (to a game, etc.) Any ideas as to how to keep the OBS running in background?

I'm using the GStreamer plugin, and methods described by @Kiwii @rondhi above.

UPDATE: found a weird behavior with GStreamer method;

Was finally able to keep OBS recording up until game launch. The recording was now able to record swapping to Library and subsequent Steam menus. However, in order to do this, I went to 'Decky Plugin browser' (which opened a Steam Web browser), and then when I pressed the Steam button at this point, OBS would no longer hang.

Upon launching a game from this point, the game would eventually pause the OBS instance/recording. Pressing B, or swapping back into OBS instance would resume the recording.

https://streamable.com/bkrwz1

Here you can see the hang-ups and workaround, at least to access library.

Sorry not knowleadgable with the way it makes xwayland windows, but does it spawn a new instance for each of these steps it's getting hung up on? By opening library from Decky plugin, it's becomes a nested instance and doesn't have to swap?

Is there anyway to tell the gstreamer pipeline to swap to the foreground/focused xwayland instance? That way the Gstreamer always has something to stream and doesn't hang?

@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!

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