[Guide] Two PC configuration without Capturecard

Jack0r

The Helping Squad
ehm Keyframe interval is normally:
g = FPS * desired Interval
g = 30 * 2 = 60 for 30fps streaming
g = 60 * 2 = 120 for 60 fps streaming
 

Lebo

New Member
I'm going to have to ask for help, I apologize in advance if I missed something in my search for an answer. I am new to linux so I am sure there is something glaringly simple I missed. I have OBS installed on my gaming rig, and nginx installed on an older server box (Duel opteron tyan barebone) The problem is pretty basic, using nrw2000's nginx.conf settings I get the following results:

If I point OBS to /live/test the stream is carried forward to twitch.
of I point OBS to /transcode/test nothing is carried forward to twitch (no errors given)

Steps taken so far:
installed fresh Ubuntu 12.04LTS
installed ffmpeg - ran ffmpeg at terminal and it ran
installed nginx per dodgepong's guide exactly including versions there. - stream from OBS forwards with dodgepong's nginx.conf
went through nrw2000's guide, overwrote dodgepong's settings with Nrw2000's. - Discovered no stream condition
removed, purged, and reinstalled ffmpeg distro (thinking it was not executing due to not being installed or active)

At this point I conjecture (in my ignorance) that perhaps nginx cannot perform the exec ffmpeg command. But I cannot find a way to test this. Thank you for taking the time to read this post. Id appreciate any help offered.
 

Jack0r

The Helping Squad
nginx has a pretty good error.log if you activated that in your config. you should normally see a pretty clear error if it cannot find ffmpeg and an access error if it has no access to ffmpeg.
you could also try using avconv instead of ffmpeg, see if that works
 

Lebo

New Member
Wow, thank you! I didn't even think about an error log. I'll check it.

Alright, sadly the error.log is blank >=(

Here is the config change I am using:
Code:
rtmp {
    server {
       listen 1935;   
       chunk_size 4096;   

        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-dfw.twitch.tv/app/live_53394267_blahblah;
        }
    }
}

Perhaps I should be changing $name and ${name}? If so to what?
 

Jack0r

The Helping Squad
yea the ffmpeg setup seems wrong:
you have no application that is called trans, so that should be transcode and I think you will have to tell ffmpeg which streamkey you use in OBS to stream to nginx:
-i rtmp://localhost:1935/transcode/streamkey
and for output you can use any streamkey to send it to the live application
-f flv rtmp://localhost:1935/live/anykey

So if you used "BugsBunny" as the streamkey in OBS it would look like this
exec ffmpeg -re -i rtmp://localhost:1935/transcode/BugsBunny -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/anything;
"anything" will then be pushed to twitch
 

Lebo

New Member
Thank you for your continued patience and help. If I didn't think this process would help others I would have stopped posting here because honestly I'm pretty stumped and at the point of trying crazy things (see below).

I have make your suggested changes. Replacing the $names with actual keys and fixing the path. However I still an not gettinga stream. Doing some research that I didn't really take all in from some other sites I gathered I could use the ffmpeg from the config as a command line execute. So I made a new application named test and gave it live on and re order off. Pointing obs at it I was able to watch the stream on VLC. Then tried the ffmpeg pointing to the new application test/test.

Turns out while it sees the new app to stream it doesn't recognize the libx264 codec! So I will next try to reinstall ffmpeg in some way that gives me the libx264 that the distro is not including. Wow this has been a trip so far but I guess being a Linux noob doesn't help.
 

Jack0r

The Helping Squad
Yea I just tested on a fresh ubuntu installation, with the deprecated ffmpeg it will not work. I quickly tested it with the static release which you can download of the ffmpeg page and that will work just fine.
 

theinzane

Member
Hi, I am currently trying to set this up. Love the idea of eliminating my capture card. Since I am using a 144hz monitor I get some massive stuttering and tearing on my capture card unless I run my monitor at 60hz which I do not want to do.

I've got the rtmp server all setup and have obs streaming to the rtmp server. The server is then forwarding the video to twitch.tv but I am getting some severe lagging, it seems as if the rtmp server isnt doing any transcoding at all and it is attempting to hand off the uncompressed video straight to twitch.tv

Here is my config file.
Code:
rtmp {
    server {
       listen 1935;   
            chunk_size 4000;   

        application transcode {
            live on;
            record off;            
            exec ffmpeg -re -i rtmp://localhost:1935/trans/test -vcodec libx264 -preset fast -x264opts nal-hrd=cbr:force-cfr=1:keyint=120 -r 60 -b:v 3000k -maxrate 3000k -bufsize 3000k -threads 12 -s hd720 -sws_flags spline -acodec copy -f flv rtmp://localhost:1935/live/test;                   
        }
        application live {
             live on;
             record off;
             push rtmp://live-ams.twitch.tv/app/(streameditedout);
        }
}

Some information about my setup:

I am using a AMD 8350FX in the RTMP machine and intend on streaming at 720p/60fps.

When the rtmp server is running and I have it streaming to twitch, I am getting 0% cpu usage on the machine thats supposed to be doing the encoding. I have a feeling that the error is either with my config of ngin-x or maybe ffmpeg. Any help would be greatly appreciated.


*Edit*

Also should have mentioned if I go to my twitch dashboard while attempting to stream I get these notifications

Details

Max keyframe interval is currently at 4.267 seconds. Please set it to 2 seconds.
The broadcast is not set to constant bitrate (CBR). [Current average: 4495 kbps, current max: 13664.0 kbps]


*Edit 2*

If I just go with the code
Code:
rtmp {
        server {
                listen 1935;
                chunk_size 4096;

                application live {
                        live on;
                        record off;
                }
        }
}

And connect to my rtmp server with VLC media player I also get the same stuttering so I have a feeling I may have a problem with my nginx setup.

I should also note that I am extremely new with ubuntu. In fact I installed it for the first time today to try and get this setup working.
 

Jack0r

The Helping Squad
chunk_size 4000 -> I normally use 8192
-re -> I so far never used because of its description in the manual:
"Should not be used with actual grab devices or live input streams (where it can cause packet loss)."
-threads 12 -> is normally not necessary and could cause bad load, maybe remove that

I tested quickly with your chunksize and -re but could not produce any stutter, so I would try removing -threads and checking your cpu usage on the linux machine. On the commandline "top" is a good system monitor, or you boot into a desktopmanager if you can and check with the normal system monitor :)

You can also check the ffmpeg commando by hand, remove it from the config for a bit and start it yourself using the commandline. see if it throws any errors.
 

theinzane

Member
Jack0r said:
chunk_size 4000 -> I normally use 8192
-re -> I so far never used because of its description in the manual:
"Should not be used with actual grab devices or live input streams (where it can cause packet loss)."
-threads 12 -> is normally not necessary and could cause bad load, maybe remove that

I tested quickly with your chunksize and -re but could not produce any stutter, so I would try removing -threads and checking your cpu usage on the linux machine. On the commandline "top" is a good system monitor, or you boot into a desktopmanager if you can and check with the normal system monitor :)

You can also check the ffmpeg commando by hand, remove it from the config for a bit and start it yourself using the commandline. see if it throws any errors.


I tried removing the -re and the -threads 12 and adjusted the chunk size to the 8192 that you stated but I still get the stuttering.

As for the checking ffmpeg commando by hand, im not exactly sure what you mean. I am extremely new to ubuntu so I may need that explained a bit further.

*Edit*

I tried typing ./ffmpeg and a bunch of text came up, didn't see anything about any errors

Also I would like to note that if I remove the ffmpeg from the config file and just have the video going to the rtmp server and I connect to the server with vlc media player. The stuttering is still there.
 

theinzane

Member
I have a feeling its a problem with my nginx configuration.

Here is the whole config file
Code:
#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}


    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

    #    location / {
    #        root   html;
    #        index  index.html index.htm;
    #    }
    #}
}
rtmp {
    server {
       listen 1935;   
            chunk_size 8192;   

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

theinzane

Member
I figured out my problem.

It was a 2 part problem. This quoted part was one.

Jack0r said:
Yea I just tested on a fresh ubuntu installation, with the deprecated ffmpeg it will not work. I quickly tested it with the static release which you can download of the ffmpeg page and that will work just fine.

And the second problem was I had the first PC streaming to the application that was streaming to twitch instead of passing it through the encoder first. Just a small error on my 1st. PC's obs settings.

Its all working now though thanks for the help.
 

theinzane

Member
I have ran into a new problem.

As the setup suggest I am using the Intel Quicksync to stream to the RTMP server on the 2nd PC. I've tried 1080p at 60fps lat a 25,000 bitrate like the guide suggests but the obs encoder ends up skipping frames and eventually falling so far behind that it cannot recover. I can do 720p at 60fps but then I have to downscale on the 1st PC before sending it to the rtmp server.

I am using a 4770k cpu in the first pc and made sure I have updated the the Intel(R) HD4600 IGPU drivers.

Is this just to much for Quicksync/IGPU to handle?
 

Jack0r

The Helping Squad
Yea I had a similar problem, I noticed, the higher bitrate you are trying to use, the more frames QuickSync will drop. We would have to ask Palana for more info on that, but I guess 1080p60 is too much for it at reasonable bitrates. What I personally do is use the ultrafast preset for 1080p60.
Roughly 15% cpu usage + 10% gpu usage from OBS while capturing BF4 at that resolution are awesome and to me, perfectly playable. (I use a 4770 without the K)
 

theinzane

Member
I appear to have found a solution to the frame skipping problem. It appears that I had a source that was not playing nicely, it was a window capture of a browser window, as soon as I removed that source from the scene everything began to operate smoothly again. I find this odd since thats usually a monitor capture issue with windows 7 but I was neither using a monitor capture and im using windows 8.1. Odd.

I also overclocked the IGPU up to 1700mhz which im sure helps a bit too.
 

Spooneh

New Member
gauss5546 said:
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?


I understand that this thread doesn't quite achieve this, judging from the replies but is this possible?

I have two computers (one for me and one for my gf) and I basically want the option to show my gf's gameplay without a capture card? Is it possible? Can someone point me in the right direction? sorry I am just massively confused right now. Thanks.
 

spiritsancti

New Member
is it possible to do like gaming rig -> capturecard in second pc for encoding -> 3rd pc as rtmp server with ffmpeg encoding to get even better quality at lower bitrate . ?
 

Jack0r

The Helping Squad
Doing 2 encodings unfortunately will not increase the quality, but you can of course do it. You can for example capture a high quality recording on the pc with the capture card and do the encoding for your stream on the 3rd pc.
 

okuRaku

New Member
First off - thanks for the guide and all for your comments. I've been trying to get my own setup working and having a lot of trouble. I've had no problem really getting the gaming PC to connect to the transcoder but 9/10 configurations I try it doesn't get forwarded to twitch. When I have successfully gotten it to twitch, their quality measure always says my keyframe setting is wrong, that CBR isn't on, and I observe the 1 second freeze every 5 seconds or so that I think some others have described in the thread.

Typical twitch errors I'm seeing:
Max keyframe interval is currently at 4.084 seconds. Please set it to 2 seconds.
The broadcast is not set to constant bitrate (CBR). Current average: 1818 kbps, current max: 3481.0

First, I tried the exact setup in the OP and by compiling my own ffmpeg. That didn't work at all. Next I tried a static ffmpeg (daily build) and that worked but with the limitations I mentioned no matter what I tweaked. Finally I've been trying avconv but haven't been able to get it to show up on Twitch yet.

I feel like there must be something fundamental I'm doing wrong; like my exec line is just bad somehow but the error log for nginx isn't helpful...

Here's some configs I've tried:

Code:
worker_processes 1;
error_log logs/error.log;
events {
        worker_connections 1024;
}
rtmp {
        server {
                listen 1935;
                        chunk_size 4096;

                application transcode {
                        live on;
                        record off;
                        exec avconv -i rtmp://localhost:1935/transcode/stream -c:v libx264 -x264opts keyint=120:min-keyint=120 -preset medium -r 60 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 3500k -s 1280x720 -c:a copy -f flv rtmp://localhost:1935/live2/anykey;
                }
                application live2 {
                        live on;
                        record off;
                        push rtmp://live-dfw.twitch.tv/app/live_1234567890;
                }
        }
}

Here was another config I tried using a released static build that does make it to twitch but has the freezing problem I mentioned (visible in this vod http://www.twitch.tv/okurakutest/b/497991960)

Code:
worker_processes 1;
error_log logs/error.log;
events {
        worker_connections 1024;
}
rtmp {
        server {
                listen 1935;
                        chunk_size 8192;

                application transcode {
                        live on;
                        record off;
                        exec /home/myuser/ffmpeg_static/ffmpeg-2.1.3-64bit-static/ffmpeg -i rtmp://localhost:1935/transcode/stream -vcodec libx264 -preset medium -x264opts nal-hrd=cbr:force-cfr=1:keyint=120 -r 60 -b:v 3500k -minrate 3500k -maxrate 3500k -bufsize 3500k -threads 6 -s 1280x720 -sws_flags spline -acodec copy -f flv rtmp://localhost:1935/live/anykey;
                }
                application live {
                        live on;
                        record off;
                        push rtmp://live-dfw.twitch.tv/app/live_312345;
                }
        }
}

Any ideas?
 

Vip3rr

New Member
First, I wanted to say thank you for this guide. I have finally been able to get it to work and i am loving having a second pc for this. The one question I ask is about the below information.

nrw2000 said:
-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.

Right now I have OBS on my first PC downscaling it to 720p BEFORE going to my second PC doing the encoding. With the above information, should I be leaving my OBS settings on the 1st pc at 1080p and let the second pc do the downscaling? I just want to be able to get the best quality possible, and if the first PC downscaling is giving worse quality, I would like to know. Just wanted to see what everyone thought and what was really meant by the above. Thank you all for your time.
 
Top