Streaming videos to Steam from a server
If you're a game developer with a game on Steam, chances are you might want to stream content to Steam, whether it's pre-recorded, live stream vods or custom made trailers - it's a whole thing!
Streaming from OBS is pretty straight forward, there's even documentation from Steam on how to do all that, but I wanted to stream without having to run a PC 24/7 or have it run on my own PC. Though... I do have a computer running 24/7 already, my server in the cloud!
Digital Ocean - the server
I use digital ocean to host content, it's a great host. They have a server for $5 a month that should do what you need. It should work on any server where you can install software (ffmpeg) and run commands to execute it though.
Installing ffmpeg - the software to run
To start, you'll need to install ffmpeg. I tried using the package manager to install it but that gave me a version that was too old.
Pay attention to the version of ffmpeg (> 4.0)
ffmpeg --version
must report a version number higher than 4.x for these instructions to work (`stream_loop` is needed).
On an ubuntu server like I have, typing sudo apt install ffmpeg
into the terminal and hitting enter gave me ffmpeg. Once installed, typing ffmpeg
and hitting enter should print usage information.
Instead, I grabbed a static build that acts as a normal binary file that you can just run. I got it from this website:
I downloaded the file using wget <the url of the version to download>
. In my case, ffmpeg-release-amd64-static.tar.xz
- for a 64 bit server. I used the git version instead of release, but either is fine. Just take note for the folder name it generates. You can use ls
followed by enter to see the file in the folder.
This places the downloaded archive into the folder you're in, and you can run tar -xvf ffmpeg-release-amd64-static.tar.xz
which is just unzipping the compressed archived. Again ls
will tell you the exact name.
Since this put the files inside a folder, I can run ./ffmpeg-git-20220526-amd64-static/ffmpeg --version
- which is the binary - and have it print the version. Note that below I will just use ffmpeg <stuff>
for clarity which is the short name. Use this long version instead when running the command.
Converting the video
Get your video file onto the server. This can be done with file uploading, or using wget to download it say, from a dropbox link. I used wget + dropbox link with dl=1 instead of dl=0 (using the share link option and pasting the link, and changing it).
I initially tried my normal video file, an mp4, but for some reason it wasn't working. I stumbled on this post which gave a command that converts to something that works.
Below I include MY_VIDEO_FILE.MP4
and VIDEO_TO_STREAM.flv
as file names. You must replace those with your own file names.
MY_VIDEO_FILE.MP4
and VIDEO_TO_STREAM.flv
as file names. You must replace those with your own file names.I basically copied it as is, and execute it:
ffmpeg -i MY_VIDEO_FILE.MP4 -c:v libx264 -preset medium -b:v 3000k
-maxrate 3000k -bufsize 6000k -vf "scale=1920:-1,format=yuv420p" -g 120
-c:a aac -b:a 128k -ac 2 -ar 44100 VIDEO_TO_STREAM.flv
This asks ffmpeg to convert the video to a specific format, and save it in a file called VIDEO_TO_STREAM.flv
. This file will be what we ask ffmpeg to send to Steam.
Streaming the video
On the Steam upload page it gives you two pieces of information.
- Upload server - usually
rtmp://ingest-rtmp.broadcast.steamcontent.com/app
- Upload token - this is like a password, keep it secret. This is the "key" that you need.
These get combined into one url like this: rtmp://ingest-rtmp.broadcast.steamcontent.com/app/YOUR_UPLOAD_TOKEN_HERE
We then ask ffmpeg to stream the video on a loop. That's the-stream_loop -1
part. The rest is just telling it to copy the data directly to the given url.
ffmpeg -re -stream_loop -1 -i VIDEO_TO_STREAM.flv -c copy -f flv
"rtmp://ingest-rtmp.broadcast.steamcontent.com/app/YOUR_UPLOAD_TOKEN_HERE"
If you run this and nothing goes wrong, you'll see it start printing out a number of frames, and upload speed and more details.
That should mean in about a minute or two (there's delay sometimes) your Steam Watch Page ("Your broadcast URL" on the upload page) will have the video live. It can take a few more minutes before it shows on a game or event page, if all configured correctly.
Running in the background
If that works you're in a good place! But this runs in the foreground, so if you quit the terminal it'll stop streaming. We can tell the command we just ran to run in the background by adding an &
after it.
The other issue is it's quite chatty, while showing so much info. It's nice to see the info, but on a server nobody is likely watching the infinite progress bar. We use -nostdin
and -loglevel error
to keep it only logging errors.
The final command to run
ffmpeg -nostdin -loglevel error -re -stream_loop -1 -i VIDEO_TO_STREAM.flv -c copy -f flv "rtmp://ingest-rtmp.broadcast.steamcontent.com/app/YOUR_UPLOAD_TOKEN_HERE" &
Check that it stays running
Instead, type
exit
and hit enter to log out, which will keep it running. You can also use the
screen
command if you know how or want to look that up. You can also make it run automatically on start, set it as a service, all that fun linux server stuff that is too much for this post.Hope that helps!
There's other services like those mentioned here by Steam that support streaming videos, but their pricing and limitations may not fit your needs.
If possible, doing it yourself might be a good fit. Especially if you have someone you know who can help with the terminal or server stuff in case there's issues.
Good luck and have fun.
Obligatory promotion
You can wishlist Mossfield Origins on Steam! You might even see a stream running from a server! Read about Mossfield Origins here. Check out the Future Of Play Direct event on Steam.