[Guide] Two PC configuration without Capturecard

Beast96GT

Member
Thanks for the quick response, Bamse. That's exactly what I thought, so I'm baffled as to why I can stream using the Quick Sync or x264 setting in OBS on PC1 to NGINX/FFMPEG on PC2 no problem, but FFMPEG fails when I set OBS to use NVENC. To make sure that OBS was working properly, I streamed straight to Twitch from PC1 using NVENC with no problem.

Basically FFMPEG acts like only the audio part of the stream is working--as best as I can tell. I compiled FFMPEG using the compilation walk-through on FFMPEG.org:
https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu

I'm at work right now and don't have access to my PC2 for the command line parameters, but it was basically copied verbatim from Jack0r's NGINX setup on Helping Squad (mucho thanks to him, btw).

I'll paste it here in a few hours at lunch along with the message I get from FFMPEG. Maybe that will provide some insight. Thanks.
 

Beast96GT

Member
Hmm... So I went home at lunch to get the command line, and decided to test it out... and it worked. Yep, it started streaming NVENC to FFMPEG with no problem... and I have no idea why. The only thing I could think of was needing to possibly reboot my streaming setup after updating the Nvidia drivers.. but even that doesn't sound right.

For curiousity sake, this is the command line I'm using to test for 720p:
exec ffmpeg -i rtmp://192.168.1.8/live/1080 -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://192.168.1.8/live1/720;

My goal is to hit 1080p @ 60fps--we'll see. I'm going to have to just test the settings out, but any tips on bit rates and such for NVENC in OBS and sending to FFMPEG?

Thanks. By the end of this, I'll probably have the best looking stream of garbage that nobody wants to watch.. lol!!
 

GillyMoMo

Member
Hmm... So I went home at lunch to get the command line, and decided to test it out... and it worked. Yep, it started streaming NVENC to FFMPEG with no problem... and I have no idea why. The only thing I could think of was needing to possibly reboot my streaming setup after updating the Nvidia drivers.. but even that doesn't sound right.

For curiousity sake, this is the command line I'm using to test for 720p:
exec ffmpeg -i rtmp://192.168.1.8/live/1080 -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://192.168.1.8/live1/720;

My goal is to hit 1080p @ 60fps--we'll see. I'm going to have to just test the settings out, but any tips on bit rates and such for NVENC in OBS and sending to FFMPEG?

Thanks. By the end of this, I'll probably have the best looking stream of garbage that nobody wants to watch.. lol!!

Since you are transcoding it, you could actually send that at 10000 if you wanted to, since it's going to downscale in the first place. This isn't a bad idea since this is an internal stream. I know with NVENC you need quite a bit of bitrate to keep a clean stream going. I would try it and see what happens.
 

Bamse

Member
I use QS myself and send in about 40000 from my gaming PC to my stream-'puter. Tried going higher and a bit lower and when I went higher I didn't see any visual gains, and going lower (up to a certain point) didn't do much either .... so I thought I'd stick with a bit of excess just to make sure QS and the transcode wasn't the culprit or bottleneck for anything.
One thing that I was looking for was if there was a difference in cpu load on my streaming pc depending on the bitrate of the incoming source. I tried replicating the content as good that I could and there was no real difference no matter if I send in 20k or 40k.
 
ffmpeg doesn't need to be built with anything from NVEnc included - your gaming PC (OBS) is just streaming video to your 2nd box at a much higher bitrate. Anything about its format (container format, etc.) won't be specific to NVidia in any way.

One thing I did find not too long ago (around a month, maybe month and a half ago) -- much to my disappointment, was that it was apparently impossible to get an NVEnc-generated video stream out of my first PC from OBS at a correct 30fps framerate. I even set OBS up on the first PC to write a copy of the original video file before it was transcoded by the 2nd to see if it was something ffmpeg was doing wrong. It just wouldn't do it - the frame rate would show in one field in XBMC's (my standard "watch the playback for quality on the big screen method", LOL) "video data" screen you can turn on while it's playing - but the one that actually shows the playback framerate would always show ~20fps, +/- ~4-5fps, and a BUNCH of discarded frames. (ffmpeg would transcode it, it just didn't come out at corret framerate. But I proved it was "wrong" before ffmpeg ever even saw it to transcode it down to the usual stream bitrate).

Worked fine as long as I told OBS I wanted 60fps framerate and reconfigured the 3 ffmpeg settings for 60fps.

Dunno if thats what you were seeing or not...

Anywho I've quit using NVEnc and legacy OBS - had to give NVEnc up to try out OBS-MP. It's not perfect by any stretch but it's definitely better enough that I don't want to go back, and have x264 profiles I'm happy enough with for output from my first PC with high bitrate and pretty low-ish CPU.
 

Bamse

Member
In your "live" application you specify where to push to.

Code:
            application twitch {
            live on;
            record off;
            push rtmp://live-jfk.twitch.tv/app/[streamkey];
             }

Just change the address to what service you want to stream to or by all means, add additional line with a second destination ... and a third and a forth if you want to :)
When I stream I stream to both twitch and hitbox at the same time.
 

kihnyx

New Member
In your "live" application you specify where to push to.

Code:
            application twitch {
            live on;
            record off;
            push rtmp://live-jfk.twitch.tv/app/[streamkey];
             }

Just change the address to what service you want to stream to or by all means, add additional line with a second destination ... and a third and a forth if you want to :)
When I stream I stream to both twitch and hitbox at the same time.

Ah, figured that was all. Could I possibly do different encoding profiles for each service though?
 

Bamse

Member
afaik, to do several encoding profiles you need several "in" applications, i.e separate instances of ffmpeg running.
In reality that'd be more machines running nginx I guess ... ;D
 

viktor6

New Member
Guys you need to when streamers Twitchy users can choose the quality of the stream (source, high, medium, low, mobile)
And why not receive notification about the launch of Stream
 

Bamse

Member
... wat? :)
Yes, you need to do several transcodes to emulate what twitch does when they offer different qualities to partners and other "popular" non-partners.
Notifications has nothing to do with this solution combined with Twitch.
 

viktor6

New Member
when I run the stream OBS> Twitch the notice comes to email,
And when I run stream OBS> Nginx> Twitch no notifications to email,
 

Bamse

Member
I hear you, but notifications are triggered when a stream starts and it is detected and processed at Twitchs' servers. You have to send something pretty messed up from nginx so Twitch doesn't even think you stream for the notifications not to work. If you stop and start streaming to frequently the notifications wont be sent either ... think of it like an anti-spam protection.

Besides, we can't even remotely start to help you with the information you provided. No logs, no nginx config ... no nothing :)
 

viktor6

New Member
How do nginx to change the name (Title) Stream on Twitch

Code:
user www-data;
worker_processes auto;

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

pid /run/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;


# HTTP can be used for accessing RTMP stats
    server {

        listen      80;

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

        # This URL provides RTMP statistics in XML
        location /stat {
            rtmp_stat all;

            # Use this stylesheet to view XML as web page
            # in browser
            rtmp_stat_stylesheet stat.xsl;
       #allow 127.0.0.1;
        }

        location /stat.xsl {
            # XML stylesheet to view RTMP stats.
            # Copy stat.xsl wherever you want
            # and put the full directory path here
            root /home/working/nginx-rtmp-module-master;
        }
    location /nclients {
       proxy_pass http://127.0.0.1/stat;
       xslt_stylesheet /var/www/html/nclients.xsl app='$arg_app' name='$arg_name';
       add_header Refresh "3; $request_uri";
    }

        # rtmp control
        location /control {
            rtmp_control all;
        }

        location /hls {
            # Serve HLS fragments
            # alias /tmp/app;
       alias /var/www/html/video;

            expires -1;
        }

    }
}

rtmp {
    server {
        listen 1935;
        chunk_size 4096;

        application restream {
      #      live on;
      #      record off;            
      #      exec ffmpeg -re -i rtmp://localhost:1935/restream/$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-arn.justin.tv/app/live_*********;
live on;
    meta copy;
    # Twitch source
                    push rtmp://live-arn.justin.tv/app/live_***************;

   # youtube source
                    push rtmp://a.rtmp.youtube.com/live2/*********************;
                    #push rtmp://a.rtmp.youtube.com/live2/your-key-here;
                    push rtmp://live-arn.justin.tv/app/live_*********************;
}
}
}
 

Bamse

Member
1. You can't change stream title with the nginx.conf alone, not with the push-statement anywho.
2. Is that your live config? You basically don't do anything with all the stuff commented out :)
 

Bamse

Member
All lines starting with # means that they are commented out are are not used. They will be ignored and therefore not used.

Have a look at this guide as a good starting point: http://www.helping-squad.com/two-pc-streaming-or-recording-without-a-capturecard/

There is no "ultimate config" that suits everyone, base out of what is said and shown in the guide and start testing, but remember this is a web server modified with a module that enables it to recieve, transcode, push out a RTMP stream.
The options on what you can do with it is limited and needs to be done with other client side tools (like updating stream titels and what not).
 

viktor6

New Member
I was correct configuration nginx.conf
I am doing so OBS = 192.168.0.105, nginx server = 192.168.0.110
Code:
user www-data;
worker_processes auto;
error_log /var/log/nginx/rtmp_error.log debug;
pid /run/nginx.pid;

events {
    worker_connections 1024;
    # multi_accept on;
}

http {
        allow all;
        deny all;
        access_log /var/log/nginx/rtmp_access.log;
        include       mime.types;
        default_type  application/octet-stream;   
        sendfile on;
    keepalive_timeout 65;

server {
        listen       80;
        server_name  localhost;


        location / {
            root /var/www/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 /var/www/html;
        }

        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }

        location /stat.xsl {
            root /var/www/html;
        }        
    }    
}

rtmp {
    server {
        listen 1935;
        chunk_size 8192;
       
    #Restream
        application live {
                    live on;
                    meta copy;
                    exec ffmpeg -i rtmp://192.168.0.105/live/$name -vcodec libx264 -preset veryfast -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -b:v 3000k -maxrate 3000k -bufsize 3000k -s 1280x720 -sws_flags spline -r 30 -acodec copy -f flv rtmp://localhost/live1/${name};

         }
         application live1 {
                    live on;
                    meta copy;
         
                    # Direct streaming:

            # GamingLive
                    push rtmp://broadcastEU.gaminglive.tv/push/sneaky4oe?secret=******************;

            # HitBox
                    push rtmp://live.hitbox.tv/push/sneaky4oe?key=************; #hitbox

            # Cybergame source
                    push rtmp://premium.cybergame.tv:1953/premium/sneaky4oe?key=*****************; #cybergame source

            # dailymotion (restream.io)
                    push rtmp://publish.dailymotion.com/publish-dm/*******?auth=****************************; #dailymotion

            # Twitch source
                    push rtmp://live-arn.justin.tv/app/live_**************************;
            }

    }
}
 

Bamse

Member
Looks good apart from one thing. IP on the ffmpeg exe-line should all be either localhost or the IP of the server/machine running nginx, not the client ip.

Also as a small precaution is that streaming to all those services at once would require you to have a total upload of 5x3000kbit/s, so 15Mbit/s, plus possible bursts and overhead (and whatever bandwidth required for games, voip etc etc). If you have a connection that can handle that you should be good to go of course :)
 
Top