[Guide] Two PC configuration without Capturecard

nrw2000

New Member
General requirements
First PC:
  • Intel Quicksync support
Second PC:
  • RTMP server with NGINX under Ubuntu (ubuntu server virtual machine or standalone ubuntu server)
  • Good CPU. I use Intel Core I7 3770K overclocked to 4500MHz. It allow to transcode 1080p with fast preset and 720p with medium preset. Free memory not important, because ubuntu use 200k maximum.
The main idea is: streaming by first PC with high bitrate and transcode it by second PC.

First PC configuration (OBS settings)
Encoding:
  • Use CBR - enabled
  • Use custom buffer size - enabled
  • Max bitrate
    • 25000 for 1080p
      15000 for 720p
  • Buffer size - 7000. Buffer size more then 7000 can cause periodical disconnections from nginx.
Broadcast settings:
Video:
  • Set resolution and FPS according to your needs
Advanced:
  • Use Quick Sync - enabled

Second PC configuration
You need to install NGINX with rtmp module: (the default nginx comes without rtmp support)
https://obsproject.com/forum/viewtopic.php?f=18&t=5873
https://obsproject.com/forum/viewtopic.php?f=18&t=2651

NGINX settings (/usr/local/nginx/conf/nginx.conf):
Code:
rtmp {
    server {
        listen 1935;   
            chunk_size 4000;   

        application transcode {
            live on;
            record off;           
            exec ffmpeg -re -i rtmp://localhost:1935/trans/$name -vcodec libx264 -preset medium -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -r 30 -b:v 2000k -maxrate 2000k -bufsize 2000k -threads 12 -s hd720 -sws_flags spline -acodec copy -f flv rtmp://localhost:1935/live/${name};                  
        }
        application live {
             live on;
             record off;
             push rtmp://live-lhr.twitch.tv/app/twitch_key;
        }
    }
}

Description of some ffmpeg settings
  • preset medium. Corresponding OBS option - x264 CPU Preset. Change according to your CPU.
  • keyint=60. Corresponding OBS option - Keyframe Interval. Replace 60 by [OBS FPS setting]*2.
  • nal-hrd=cbr. Corresponding OBS option - Enable CBR padding.
  • force-cfr=1. Corresponding OBS option - Use CFR.
  • r 30. Corresponding OBS option - FPS. Replace 30 by OBS FPS setting.
  • b:v 2000k. Corresponding OBS option - Max Bitrate. Set according to your needs.
  • maxrate 2000k. Corresponding OBS option - Max Bitrate. Set according to your needs.
  • bufsize 2000k. Corresponding OBS option - Buffer size. Set to Max Bitrate or use custom buffer size according to your needs.
  • threads 12. Set to 1.5 * logical processors, rounded down. In some cases ffmpeg/avconv can't detect CPU and use only one thread, so better to set it manually.
  • s hd720. Resolution of target video. Also you can use following syntax: -s 1280x720. Video quality will be better in case you use downscaling by ffmpeg instead of first PS, because quicksync add too much sharpness into downscaled video. Remove this option in case you are streaming in 1080p.
  • sws_flags spline. Downscale method. You can try "lanczos" method instead of "spline" as alternative. Remove this option in case you are streaming in 1080p.
  • rtmp://live-lhr.twitch.tv/app/twitch_key. Replace by your favorite stream server and key. List of twitch.tv servers: http://bashtech.net/twitch/ingest.php

Why you should send stream to "application live" and then push it to twitch?
If you send stream to twitch directly, it will lag. I have no idea why.

FFMpeg vs AVConv
Default ubuntu a/v converter is avconv. If you execute ffmpeg, ubuntu will execute avconv instead. It is not bad, but "real" ffmpeg and avconv has some different command line settings. For example -x264opts parameter not supported by avconv and I don't know how to define nal-hrd=cbr (it is Enable CBR padding in OBS) in avconv. I use "real" ffmpeg installed according to following guide http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide.
If someone know how to use avconv and correspond to new Twitch requirements, please let me know.

P.S. Sorry for my English :)
 
Last edited by a moderator:

Jack0r

The Helping Squad
Glad you liked dodgepongs and my Guides :) And I didnt know about the buffer setting, this could explain some trouble I had recently, will investigate this!

Oh and one thing to notice: nginx-rtmp-module on windows cannot use "exec" so you would have to run ffmpeg on your own in this case. But its not a big problem. On a Linux machine you can use the nginx configuration as in your example.

Thanks for the Guide!
 

nrw2000

New Member
Jack0r said:
Oh and one thing to notice: nginx-rtmp-module on windows cannot use "exec" so you would have to run ffmpeg on your own in this case. But its not a big problem. On a Linux machine you can use the nginx configuration as in your example.
Guide corrected, thanks.
 

nrw2000

New Member
Jack0r said:
And I didnt know about the buffer setting, this could explain some trouble I had recently, will investigate this!
Some magic here. I have two PC: PC1 - Intel Core I5 2500K, PC2 - Intel Core I7 3770K

1 case
PC1 OBS+QuickSync -> PC2 Ubuntu+Nginx. Buffer size more then 5000K sometimes cause disconnection from nginx.

2 case
PC2 OBS+QuickSync -> PC1 Ubuntu+Nginx. Big buffer works fine.

It's look like PC1(Intel Graphics HD 3000) has quicksync buffer problem, but PC2(Intel Graphics HD 4000) not.
 

dodgepong

Administrator
Community Helper
Nice guide. It's worth noting that the RTMP server needs to have a good CPU to do the transcoding. I know that in my guide, I make a point of saying that a simple RTMP server doesn't need to be very powerful, but in this case, it actually does.
 

nrw2000

New Member
dodgepong said:
Nice guide. It's worth noting that the RTMP server needs to have a good CPU to do the transcoding. I know that in my guide, I make a point of saying that a simple RTMP server doesn't need to be very powerful, but in this case, it actually does.
CPU requirements added, thanks.
 

nrw2000

New Member
z0rz said:
Will the end quality be better if the first PC encodes regularly instead of using QSV?
No. And it doesn't make sense because without quicksync you will use CPU of first PC.
 

z0rz

Member
Yeah, just wondering if passing it through the encoder twice would clean it up at all. If it worked, it would be a cool way for users with limited upload to maybe produce a decent stream.

I'll definitely try this setup if I can ever put together a decent enough 2nd PC.
 

nrw2000

New Member
Nginx config updated.
Added part Why you should send stream to "application live" and then push it to twitch?
 

YouGotHamsted

New Member
nrw2000 im having trouble getting my secound pc to send the stream to twitch.
i would love some help if you dont mind.

kind regards
 

pervokur

New Member
sorry for my english
Is linux version of ffmpeg works better and faster then windows version?
Can i compress video with good quality with something else (not libx264)? I need to lower cpu utilisation!

I use adobe media server and ffmpeg for windows
obs-> adobe media server->
ffmpeg -> twitch
-> goodgame
-> cybergame
ffmpeg run with bat file

( how can i start 2nd OBS window?)
 

gauss5546

New Member
So if I'm understanding this correctly I can use OBS to capture one PC and send that stream to my second PC which is running the virtualbox which has my RTMP server on it and from there I can encode on the second PC and upload to my favorite streaming website.

Is that correct?
 

dodgepong

Administrator
Community Helper
No, that's not the idea behind a 2-PC setup. If you are capturing with OBS on the primary PC, you will be doing encoding on the primary PC, which is what you want to avoid.

You want to put a capture card in the second PC (the encoding PC) and the run OBS on the second PC using the capture card as input, and do encoding there.
 

gauss5546

New Member
I don't have a capture card that is why I am looking at this topic. If capture card is needed then the title of the post needs to be changed.
 

Jack0r

The Helping Squad
Well the topic Author is not using a capture card but the included quick sync encoder of newer intel CPUs. So he gets rid off the CPU usage and sends a stream with a higher bitrate than usable for streaming to his 2nd PC.
Dodgepong is right with the point that its still being encoded on the first PC, although done by the integrated GPU. The only way to completely remove any encoding off your first PC is the usage of a capturecard.
 

moraldino

New Member
nrw2000 said:
If someone know how to use avconv and correspond to new Twitch requirements, please let me know.

CBR: "-minrate 3500k -maxrate 3500k"
Basically the same bitrate you're using for output at both flags

Jack0r said:
ehm Keyframe interval is normally:
g = FPS * desired Interval
g = 30 * 2 = 60 for 30fps streaming
g = 60 * 2 = 120 for 60 fps streaming
 
Top