Twitch streaming using two machines WITHOUT a capture card!
The goal of this process is to take load off your CPU on your gaming machine and improve your stream quality.
Machine 1, The gaming PC.
Machine 2, A Linux (Ubuntu in this guide) box.
The gaming PC will be configured to capture and encode at a high bit-rate (20,000k) then transfer the footage to the Linux box that will re-encode it at 3500k and stream it to Twitch.
Linux set-up
Install Ubuntu Server 14.04.1 LTS ( http://www.ubuntu.com/download/server )
Download and compile Nginx with the RTMP module.
sudo apt-get install build-essential libpcre3 libpcre3-dev libssl-dev git libav-tools git clone https://github.com/arut/nginx-rtmp-module.git wget http://nginx.org/download/nginx-1.7.4.tar.gz cd nginx-1.7.4 ./configure --with-http_ssl_module --add-module=../nginx-rtmp-module make sudo make install
Set Nginx to start on boot by creating an upstart file…
sudo nano /etc/init/nginx.conf
Paste the following in to this new file… (Thanks Georg0yo, I had to amend the start on line thou)
# nginx description "nginx http daemon" author "George Shammas <georgyo@gmail.com>" start on (local-filesystems and net-device-up IFACE!=lo) stop on runlevel [!2345] env DAEMON=/usr/local/nginx/sbin/nginx env PID=/var/run/nginx.pid expect fork respawn respawn limit 10 5 #oom never pre-start script $DAEMON -t if [ $? -ne 0 ] then exit $? fi end script exec $DAEMON
Configure Nginx
sudo nano /usr/local/nginx/conf/nginx.conf
Add this to the BOTTOM of the file…
rtmp { server { listen 1935; chunk_size 4096; application transcode { live on; record off; exec avconv -i rtmp://localhost:1935/transcode/test -c:v libx264 -profile:v main -preset faster -cbr_quality 10 -re -crf 23 -r 30 -g 60 -b:v 3500k -maxrate 3500k -minrate 3500k -bufsize 7000k -acodec copy -vf crop=1920:1080:0:0 -af "volume=10dB" -f flv rtmp://localhost:1935/live/test; } application live { live on; record off; push rtmp://live-lhr.twitch.tv/app/YOUR_TWITCH_STREAM_KEY; } } }
Start Nginx
sudo initctl start nginx
Gaming PC set-up
Install XSplit broadcaster or OBS. I use XSplit since it allows me to hardware encode using my Avermedia capture card but both will support Nvidia encoding and OBS supports Intel quick sync.
Set-up a custom RTMP stream using the following details…
Stream URL : rtmp://YOUR_SERVERS_IP_ADDRESS:1935/transcode Stream Key : test Change the stream bit rate to 20,000k and the encoder to anything but x264 (Nvidia Encoder, Intel Quick sync or Avermedia)
Now when you broadcast from your gaming PC it will send the high bit-rate stream to the server, encode it using x264 then stream it to Twitch.
Breakdown of the “avconv” settings…
-i rtmp://localhost:1935/transcode/test
The input stream
-c:v libx264
Use the x264 encoder
-profile:v main
Use the “main” profile
-preset faster
Use the “faster” preset, other options are veryfast, fast, medium, slow…
-cbr_quality 10 -re -crf 23
These 3 options are advised elsewhere, research and change if needed
-r 30
The frame rate to capture at
-g 60
Key interval setting, for twitch keep this at frame rate * 2
-b:v 3500k -maxrate 3500k -minrate 3500k
Bit-rate to encode video at.
-bufsize 7000k
Buffer size should be bit-rate * 2
-acodec copy
Copy the audio codec format used on the input stream for the output stream
-vf crop=1920:1080:0:0
I have to set this since the Avermedia card outputs at 1920×1088
-af "volume=10dB"
Boost the audio by 10dB’s, feel free to disable
-f flv rtmp://localhost:1935/live/test;
The output stream. I could of just streamed right to Twitch from avconv but I did it this way so I could record the encoded stream to disk. (See the RTMP Nginx module document for record options).
You should now hopefully be streaming with less overhead vs x264 on your gaming PC.
Sources and credits…
https://obsproject.com/forum/threads/guide-two-pc-configuration-without-capturecard.6757/
Since ffmpeg is no longer supported in the latest versions of Ubuntu I made this to show how it can be done with avconv.
Hey, really appreciate the guide! It’s working on and off for me however. For some reason it doesnt broadcast the video sometimes. So Im still offline on twitch, but it shows up in the videomanager that I was online. My stat file looks like http://puu.sh/dOdrh/8df9af4d5b.png.
(As said before I had it working before, but it stopped working. I didn’t change anything.) My error log http://puu.sh/dOdMT/93b1bdc134.png. Cheers for your work!
LikeLike
It has been bullet proof for me, been using the above configuration for over 6 months now without any issues.
The error log is just complaining about a missing favicon, nothing to worry about there.
One thing I do notice is that you have more then one #clients in the first screen shot thou? Not sure if this is correct as it looks like you may have more then one connection active to the streaming server?
When you are streaming use this site ( http://r-1.ch/analyzer/ ) to check if everything is working for you.
What client software are you using, OBS or Xsplit?
When you say it has been working on and off for you, has it worked well in the past?
What CPU do you have in the streaming server?
Cheers and good luck!
LikeLike
Thanks for your fast reply!
It does indeed show two clients on each streams. I’m running OBS on shadowplay. My settings are: http://bit.ly/13H0hxq , http://bit.ly/1Hen4jd and http://bit.ly/1Hen5Uo .
The stat page looks http://bit.ly/1BkToNv when OBS isn’t streaming and http://bit.ly/1rxjfSx when I started it.
My Laptopserver has an Intel Core I7-2630QM (2.00GHz)
I’ve only recently decided to do it this way (I used to stream directly from my gaming pc). The first few times I used the laptop method it worked, but it suddenly stopped working.
It’s still not functioning correctly and I’ve got no idea why.
Cheers!
LikeLike
I just tried to stream directly (without the server). And it seems that shadowplay might be the culprit. No screen but there was sounds
LikeLiked by 1 person
Fixed it by changing the NVENC Preset to “High Quality Low Latency”. Also Razer Synapse might cause it to bug out. Works 100% now!
LikeLiked by 1 person
When you input the settings for the stream url: what is the “YOUR_SERVERS_IP_ADDRESS”? Is that the ip address of the stream pc? If so, do I use the ip address of the Ubuntu virtual machine (and if so, how do I find the virtual machine ip)? Or just the ip address if I were to run ipconfig in cmd on my regular OS (Windows 8)? Thanks in advance.
LikeLike
That would be the IP address of your streaming server (The linux server on your network)
LikeLike
Normally with virtual machines you would use port mapping to allow the host machine to connect to it. I would advise against encoding with a virtualised layer thou as you may get poor performance.
LikeLike
My codec options under rtmp are grayed out. Any Ideas?
LikeLike
What software are you using? Where are you seeing this option?
LikeLike
About to put put together a machine for this next week. Does this setup capture all (both in/out) audio as well?
LikeLike
The audio is captured on the gaming PC, encoded in the high bitrate stream and then sent to the linux server that just copys it in to the low bitrate stream. You could capture from the linux box and inject it in to the stream when encoding, but that it outside of this guide.
LikeLike
I’m really interested in pursuing this guide. My concern is that I have an old alienware M17X laptop and i don’t know how it’s going to handle a Linux server install. I also have no experience with Linux. My next concern is that you have a lot of text up there and i wanted to make sure that’s all i’d end up typing in command prompts and text files, or would i have to download other software and/or files for Nginx to run properly. I’m assuming everything up there IS the install and set-up? Thanks in advance!
LikeLike
Glad to hear you are interested! Some basic Linux knowledge is assumed by the guide such as editing text files in the editor of your choice. I picked Nano for my example as it is more friendly then vi.
If I find time I will create a Docker image that you would be able to instance, passing in certain configuration options. This would reduce the guide down to just installing Docker (One line command in Ubuntu) and running a container passing in the required options. This would hopefully make it much easier for people to get this working on other distributions of Linux besides Ubuntu too.
Stay tuned 🙂
LikeLike
Hey I can’t seem to get things to work for me. I have followed the guide and have nginx working, but nothing is showing up on the live stream. Is there anything else I need to be aware of?
LikeLike
After steaming for a couple of minutes visit this address http://YOUR_SERVER_IP/stat/
Take a screen shot of that page, upload it and reply to here with the link pal.
LikeLike
I cannot. I get a 404 error when I type in the address.
LikeLike
With some creative coding, I got something from the stat page. Below is all that is displayed.
1.7.41.1.4gcc4.8.2(Ubuntu4.8.2-19ubuntu1)Feb22201510:18:22103537313924696264849710409transcodetest6104339194882644764600452839149521192.168.0.261288FMLE/3.0 (compatible; FMSc/1.0)rtmp://192.168.0.13:1935/transcode01060544136076860H264Main04.0AACLC24800011live0
LikeLike
Both the “test” stream and the “live” stream are active so it should be streaming. I would check your API key and make sure your upload / network bandwidth can handle the settings you have used.
LikeLike