Howto: Record gameplay on SteamOS

Part 1: Get ffmpeg

passwd

Open a terminal as the desktop user.

Install an ssh server with:

sudo apt-get install openssh-server Run this command to get the ip of your SteamOS machine:

ip a s Now we connect to it through a remote machine within the same network, a.k.a. your other computer.

On Windows: connect to the ip with putty, to do this you just have to enter it and press connect.

On Mac/Linux: Open a terminal and use this command to open an ssh session:

ssh desktop@ipaddress Make sure you change ipadress to the correct ip.

Open a terminal as the desktop user

You will need to add the debian repo to your sources.list, you can do that by opening it with:

sudo nano /etc/apt/sources.list Now add these lines to the file:

## Debian Wheezy repo deb ftp:/mirror.nl.leaseweb.net/debian/ wheezy main contrib non-free deb-src ftp:/mirror.nl.leaseweb.net/debian/ wheezy main contrib non-free Close the file with Ctrl+X and press Y, then Enter to save it.

Now we create a preferences file with:

sudo nano /etc/apt/preferences Add the following lines to it:

Package: * Pin: release l=SteamOS Pin-Priority: 900 This will make sure that files from the SteamOS repo will not be overwritten during automatic upgrades.

Close the file with Ctrl+X and press Y, then Enter to save it.

Run this command to update the sources list:

sudo apt-get update

Open your sources.list file with this command:

sudo nano /etc/apt/sources.list Add the following lines to it:

## deb-multimedia repo deb http://www.deb-multimedia.org wheezy main non-free Close the file with Ctrl+X and press Y, then Enter to save it.

Now update your sources with:

sudo apt-get update This will give errors, let's fix that.

Install the deb-multimedia keyring with this command:

sudo apt-get install deb-multimedia-keyring When asked if you are sure, pick y to install it.

Update your sources again:

sudo apt-get update And now, finally, install ffmpeg:

sudo apt-get install ffmpeg

sudo apt-get remove ffmpeg sudo apt-get autoremove

First thing you'll need to do is installing the packages needed for compiling with this command:

sudo apt-get -y install autoconf automake build-essential libass-dev libfreetype6-dev libgpac-dev libsdl1.2-dev libtheora-dev libtool libva-dev libvdpau-dev libvorbis-dev libx11-dev libxext-dev libxfixes-dev pkg-config texi2html zlib1g-dev git Now we compile and install yasm, which is required for compiling libx264(Make sure you are in a folder in which you have write permission for this, preferably ~/). You can do that with these commands:

git clone git:/github.com/yasm/yasm.git cd yasm ./autogen.sh ./configure make sudo make install Go back to the previous directory with:

cd .. Time to compile libx264, a library required for the recording script which I use. It's very fast, high quality and quite compact. Anyway, here is how to install it:

git clone git:/git.videolan.org/x264.git cd x264 ./configure --enable-static --enable-shared make sudo make install sudo ldconfig Go back to the previous directory with:

cd .. Now we compile ffmpeg, multiple compile configurations will work. I personally only used a few options, but you're probably better off with this:

git clone git:/source.ffmpeg.org/ffmpeg.git cd ffmpeg ./configure --enable-gpl --enable-nonfree --enable-libtheora --enable-libvorbis --enable-libx26 --enable-zlib --enable-postproc --enable-swscale --enable-pthreads --enable-x11grab --enable-libdc1394 --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libpulse make sudo make install sudo ldconfig ffmpeg wiki [trac.ffmpeg.org] .

Part 2: Using ffmpeg

Log into your system through ssh.

Switch to the steam user with this command:

sudo su steam Run ffmpeg manually with something like this:

ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r 30 -s 1920x1080 -i :0.0 -acodec pcm_s16le -vcodec libx264 -preset ultrafast -crf 23 -threads 0 ~/recording1.mkv Credit for this command goes to Ryochan7. Change the resolution to whatever you use and the file name to what makes sense to you. You can change the -r option to change the framerate and the -crf option for less strain on the system or a smaller filesize. For instance, -crf 0 will make the recording easier on the system, if you have the harddrive space, expect multiple gigabytes per hour of recording. -crf 51 is the highest possible number iirc, which will require a powerful cpu.

Create a new file for the shell script with:

sudo nano /usr/local/bin/startrecording.sh Create your own script or paste this in there:

#! /bin/bash #set variables DIR=~/Videos FRAMERATE=30 STARTNAME=recording FORMAT=mkv export DISPLAY=:0.0 #grab resolution RES="`xrandr -d :0 --prop|grep \ connected|head -1|awk '{print $3}'`" if [ $RES == "primary" ] then RES="`xrandr -d :0 --prop|grep \ connected|head -1|awk '{print $4}'`" fi RES=${RES/+0+0/} echo $RES # make recording directories if they don't exist yet if [ ! -d ${DIR} ] then mkdir $DIR fi # set name of the recording NUMBER=1 while [ -f $DIR/$STARTNAME$NUMBER.$FORMAT ] do NUMBER=$(($NUMBER+1)) done NAME=$STARTNAME$NUMBER # start the recording ffmpeg -f alsa -ac 2 -i pulse -f x11grab -r ${FRAMERATE} -s $RES -i $DISPLAY -acodec pcm_s16le -vcodec libx264 -preset ultrafast -crf 0 -threads 0 $DIR/$NAME.mkv If you want you can change stuff like framerate and the location where files are saved. here is a quick explanation of what the script does. It pulls your currently used resolution from xrandr, then checks if the recording directory exists, if not a new directory is made, then it finds a filename which doesn't exist yet and uses that and after that the recording is finally started.

Close the file with Ctrl+X and press Y, then Enter to save it.

Set execute permissions for the script:

sudo chmod +x /usr/local/bin/startrecording.sh Now you start the recording through ssh by switching to the steam user with:

sudo su steam Then running the script with:

startrecording.sh You can end the recording by pressing q in ssh. The files can be found in /home/steam/Videos by default, the desktop user can access this folder. For playing them you can install vlc or xbmc.

Part 3: Starting the recording with keyboard or controller shortcuts

Create the script file:

sudo nano /usr/local/bin/stoprecording.sh Paste the following in there:

#! /bin/bash killall ffmpeg Close the file with Ctrl+X and press Y, then Enter to save it.

Set execute permissions for the script:

sudo chmod +x /usr/local/bin/stoprecording.sh

Open the actbkd config file:

sudo nano /etc/actkbd-steamos.conf I added the following lines to it:

# Win+R 19+125:key::su steam /usr/local/bin/startrecording.sh & # Win+Q 16+125:key::su steam /usr/local/bin/stoprecording.sh & This configuration will make you able to start the recording with Win+R and stop it with Win+Q. You can use a different configuration, for an explanation of how to do that you should scroll further down.

Close the file with Ctrl+X and press Y, then Enter to save it.

Reboot the system, after that you can use the set shortcuts.

Navigate to the udev rules folder:

cd /etc/udev/rules.d/ Make a copy of the hotplug script for keyboards:

sudo cp 98-actkbd.rules 99-actkbd-controller.rules Open the newly created file with:

sudo nano 99-actkbd-controller.rules Replace KEYBOARD with JOYSTICK and actkbd-steamos.conf with actkbd-controller.conf, this should make the file look like this:

ACTION=="add", ENV{ID_INPUT_JOYSTICK}=="?*", RUN+="/usr/sbin/actkbd -D --device $tempnode --config /etc/actkbd-controller.conf" Close the file with Ctrl+X and press Y, then Enter to save it.

Now create the configuration file with:

sudo nano /etc/actkbd-controller.conf If you have a 360 controller this is a possible configuration:

# LB+RB+A 310+311+304:key::su steam /usr/local/bin/startrecording.sh & # LB+RB+X 310+311+307:key::su steam /usr/local/bin/stoprecording.sh & If you have a different controller, or you want diferent shortcuts, look at the topic below this one.

Close the file with Ctrl+X and press Y, then Enter to save it.

Reboot the system and your controller shortcuts should work.

Find out which event number your keyboard/controller has with:

ps aux|grep actkbd It should show something like --device /dev/input/event2 for instance. Ignore things like js0, actkbd can't really use those.

Become root:

sudo su Run actkbd in showkeys mode:

actkbd -n -s -d /dev/input/event2 Use the event number which you found with the ps command

Press keys to find out key numbers.

Press Ctrl+C when you wrote the key codes which you need down.Use those in your configuration file.

Don't forget to log out the root account with:

exit

Resources for additional information

I've noticed that a lot of people have been wanting to be able to record gameplay footage in SteamOS, so I decided to make this guide. Thanks to some help from Ryochan7 and [40-1]PvtBalderick I finally can. There are quite some options for setting this up and it's quite some work, but for some people that will be worth it. There are quite a few ways to do this, but I'll be sharing the way in which it has been the most successful for me. You could also opt for using recordmydesktop or avconv for this, but this hasn't been very successful for me personally. Please note, that this has only been tested with Nvidia and AMD graphics cards. I wasn't able to get recording in SteamOS working on AMD hardware. If you run into any trouble or something doesn't work, please leave a comment.There are multiple ways to get a working compile of ffmpeg, you can either compile it from source code or install it from the deb-multimedia.org repo. Both have their advantages and disadvantages, which is why I will cover both. If ffmpeg from deb-multimedia.org works for you that is great, if you have sound issues it might be a better idea to compile it from source with pulse audio support.Before you do any of this you, make sure you set a password for the desktop user, otherwise you will not be able to use sudo or ssh. To set the password open a terminal and type this command:Ssh will allow you to access the command line of your SteamOS machine remotely through Putty(for Windows users) or openssh(for Mac and Linux users).This is the easiest way to get ffmpeg, you it might give you some issues with sound.If you already installed from deb-multimedia, you can skip this step. If you did do the first option and you are having issues with it, you might want to remove ffmpeg and run through this option anyway. You can remove your old ffmpeg installation with:Ok, now let's get started.That's it, ffmpeg is now installed and usable.If you just want to record once, this should do the trick. You need ssh for this.You can write your own script if you want, but here is how to set up my personal one. You will need a recording script if you want to create keyboard or controller shortcuts for recording or if you can't remember the ffmpeg command.Both options need a script to stop an ffmpeg recording, here is how to set that up.SteamOS already has a program for creating keyboard shortcuts installed, called actkbd. Which we will now configure to use our recording scripts.By default SteamOS uses actkbd for some keyboard shortcuts, but we can also make it use a controller instead. You could also use Xboxdrv, but I can't help you with that. The only issue with using actkbd for controllers is that the triggers and the analog sticks are not supported, this does not apply for Xboxdrv. This should work for every controller, but different controllers than the 360 controller will need a different actkbd configuration file. Anyway, here is how to set it up:You might want a different configuration for your keybinds, I'll explain how to do that here. If you completed all of the previous steps, this part will be easier, even if the configuration is not what you want yet.Installing applications from the Debian repo: http://steamcommunity.com/groups/steamuniverse/discussions/1/648814396114274132/ Debian documentation: https://www.debian.org/doc/ ffmpeg wiki: http://trac.ffmpeg.org/wiki ffmpeg documentation: https://ffmpeg.org/documentation.html previous topic on recording in SteamOS: http://steamcommunity.com/groups/steamuniverse/discussions/1/558751813706961341/#p2 Autor's website: http://users.softlab.ece.ntua.gr/~thkala/projects/actkbd/actkbd.html Edit 1: formattingEdit 2: added that using this with an AMD graphics card doesn't work.