[Guide] Two PC configuration without Capturecard

Bishops

New Member
please help me someone, this has taken 12 hours straight of my life and getting very frustrating, i installed ffmpeg to this pc, then RTMP + NGINX bundle, added this line to the end


server {
listen 1935;
chunk_size 4096;

application restream {
live on;
meta copy;
exec ffmpeg -re -i rtmp://192.168.1.3/restream/$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;
record off;
push rtmp://live-syd.twitch.tv/app/live_xxxxxxxxxxxxxxxxxxxxxxxtwitchkey;
}
}
}


i can only connect to the nginx server with rtmp://192.168.1.3/live anything else will just error, and once connected and streaming at 25000 to nginx my second pc does nothing.... fans don't even spool up as if to tell me its encoding, and nothing showing up on my twitch just says channel offline, pls help, and yes i replaced the twitch key with my own
 

Bishops

New Member
my code now looks like this


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;
}
}

only problem i have iis that i can't connect to nginx through OBS, not with "transcode" anyway, only if i put "live" after the second PC ip... also im worried about this, how do i run ffmpeg? im on windows

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.

Thanks for the Guide!"
 

Bamse

Member
yes, you can't use the exec line at all on windows ... not when I tried like 6 months ago atleast. you will need to run ffmpeg as a separate .bat file.

as an example, start ffmpeg in a loop like this (copy&paste into a .bat file):
Code:
@echo off
:ffmpeg_start
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};
goto ffmpeg_start


In nginx.conf you basically just declare the application with it's options and totally omit the exec line. Example
Code:
application transcode {
live on;
record off;
}

Your application called live is fine as it is. However, if you run into VODs not being skippable in time (no option to skip time by clicking the time bar), try using the option meta off; also.
 

Bishops

New Member
thanks so much ! followed ur guide and thought i had it ! when i run the bat file it opens a cmd and my cpu spools right up as if it is encoding or ready to, but the exact same issue, i can't connect to nginx through OBS on my first PC, just time outs and server errors, unless i put /live after the IP not /transcode, and then it just skips the transcoding process and does nothing... pls halp ! should ii try to use the code by itself? i have been copying it to the end of the code that comes with nginx, also what ip? i have tried localhost, localhost:1935, and the IP of the second PC, not sure which is best, the only time i can succesfully connect to NGINX through OBS on my first PC is when i put this in URL, rtmp://second pc ip/live
 
Last edited:

Bamse

Member
Easy dude, no need for double posts :)

First off, what's the exact url you use in OBS when trying to connect?
Secondly, you call your application transcode but call it using "rtmp://localhost:1935/trans/$name", fix that and it should start working better depending on the answer above.

localhost is fine, leave it at that.
 

Bishops

New Member
only URL i can connect with is rtmp://192.168.1.3/live...

but that was only when i put 192.168.1.3 instead of localhost, should i leave as localhost and use rtmp://localhost:1935/trans/$name to connect via OBS?
 
Last edited:

Bamse

Member
ok, to be a bit clearer:

1. When connecting to OBS you should type an url that connects it to the machine running nginx. So yes, that should not be localhost unless running nginx on the local machine. Use rtmp://192.168.1.3:1935/transcode/720p (720p can be replaced with whatever you want, it doesn't matter what you type. It just has to be something. Keep it to a-z 0-9 however.)
2. As stated earlier, do not change localhost to anything in either the ffmpeg bat or nginx.conf.
3. In the ffmpeg-bat; rtmp://localhost:1935/trans/$name is wrong. It should be rtmp://localhost:1935/transcode/$name in your case.
 
Last edited:

Bishops

New Member
ok changed everything u said. left ffmpeg as localhost, didn't change anything in nginx. tried to connect via rtmp://192.168.1.3:1935/transcode/720p and still no go, just says some server error, im starting to think its my nginx code? as said before all i did was copy paste to the END of what was alrready iin nginx, is this my issue? should it be my code and my code only?

edit: tried puttiing my code only, and nginx won't open now... this is very frustrating, it seems so simple but i have only ever connected to nginx with rtmp://192.168.1.3/live, and of course nothing happened, logs say some error with end of line expecting } but my code looks fine.... im baffled, do you have teamviewer mate?

oh i also changed trans to transcode in ffmpeg,
 
Last edited:

Bamse

Member
copy&paste your entire nginx.conf and your ffmpeg batch file to pastebin or similar and link here please.

Try using the following format in obs (I only use OBS Classic so if you're using MP, not sure what they are called there):
FMS URL: rtmp://192.168.1.3:1935/transcode
Play path/Stream Key: 720p
 

Bishops

New Member
http://pastebin.com/32nTLNcA

ffmpeg

@Echo Off
:ffmpeg_start
ffmpeg -re -i rtmp://localhost:1935/transcode/$name -vcodec libx264 -preset faster -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -r 60 -b:v 2000k -maxrate 3500k -bufsize 3500k -threads 12 -s hd720 -sws_flags spline -acodec copy -f flv rtmp://localhost:1935/live/${name};
goto ffmpeg_start

nginx

rtmp {
server {
listen 1935;
chunk_size 4000;

application transcode {
live on;
record off;
}
application live {
live on;
record off;
push rtmp://live-syd.twitch.tv/app/live_blaBlubneverpostyourstreamkey;
}
}

thats EVERYTHING in my nginx config but now NGINX won't launch, will try add this to the end of a new nginx config and try to connect via obs and 720p as stream key

Yup still wont launch this is error
2016/02/22 05:15:34 [emerg] 3784#696: unexpected end of file, expecting "}" in C:\Users\StreamPC\Desktop\nginx-rtmp-win32-master/conf/nginx.conf:69
2016/02/22 05:15:57 [emerg] 2588#1784: unexpected end of file, expecting "}" in C:\Users\StreamPC\Desktop\nginx-rtmp-win32-master/conf/nginx.conf:69
 
Last edited by a moderator:

Bamse

Member
First of all, if it's your real stream key, remove your stream key from both pastebin and above immediately and generate a new one on twitch since it is now compromised.

I don't mean to be rude, but you need to slow down a bit, breathe and start from square one.
You need a complete nginx.conf and make sure nginx starts properly before you even start to involve OBS in the mix.

I say again, forget that OBS even exists until you sort out your issues with nginx.

If nginx states it has a problem at line 69, then there's something wrong at line 69 and it tells you exactly what is wrong.
Just by looking at you pastebin you are missing a "}". You close the server part, but not the rtmp part, just like the error message says :)
Start by getting a new fresh copy of a default nginx.conf. Don't do anything and just make sure nginx starts as it is. After you know nginx works, add the corrected rtmp.part _after_ the already existing nginx-config. Do not replace anything, just add to whats already in there. There's no need experimenting at this stage before you even get the basics to work.

When nginx starts without any error, then move on to the next part ... no, still not OBS. :)

In ffmpeg.bat, why do you use "-b:v 2000k -maxrate 3500k -bufsize 3500k"? What you are doing is basically a VBR-stream and twitch ain't too keen on that. Use the same value in all three cases. (Remember that using 3500kbit/s if you are unpartnered is not recommended. Head over to the "Questions and Help"-section and the 45 million identical threads on "how do I set up my stream?!" for more details ;D).
Secondly, I forgot one part when it comes to windows (I run linux myself). In the ffmpeg-bat you can't use the $-variables the same way you do on linux when it's embedded in the nginx.conf. So, change the first instance to, for example, rtmp://localhost/transcode/720p and the instance at the end to rtmp://localhost/live/720p. Do not use the $-stuff in there at all.

Now, fire the bat-file and nginx up and make sure no-one has any errors.

Now, it's OBS-time. Using the examples above, you still connect to the Custom FMS: rtmp://localhost/transcode and the stream key in this case is 720p. If you want to change the stream key part, make sure to change in BOTH OBS and ffmpeg.bat.
 

Bishops

New Member
Yes i have done all this, i had it added to the end of the default nginx config line and nginx was running, i never tried to connect to nginx with OBS unless nginx was running... rtmp://localhost/transcode will never connect me to it.... not even iif i change localhost to my IP, i don't see how changing $name in ffmpeg will allow me to connect to nginx as its running seperately....

just made fresh nginx folder and put my line at the end of it and added the extra } that was needed, launched fine, changed variables to just "restream" in ffmpeg, still can't connect to nginx, tried rtmp://192.168.1.3/transcode, rtmp://192.168.1.3/restream, rtmp://localhost/restream, rtmp://localhost/transcode, rtmp://localhost:1935/restream, rtmp://localhost:1935/transcode, rtmp://192.168.1.3:1935/restream, rtmp://192.168.1.3:1935/transcode

tried changing "transcode" in nginx to "restream", tried different FML URL's for each one, it just won't let me connect, only when i skip the transcode part and go straight to "live"

Example : rtmp://192.168.1.3/live, and that of course does nothing, just allows OBS to connect and stream to nginx, and i can find it in VLC via network stream etc

btw I REALLY APPRECIATE YOU HELPING ME THROUGH THIS, i need this to work and you are putting in time to help and i do appreciate it, i have a GPU thats way to powerful for CSGO and a nice i7 on my laptop this seems to be the solution to a half decent stream and more fps

PS: just a thought, is there any NEW updates for windows that would create these problems? i have fresh 8.1 pro on there and its not very old so i assume it has most crucial updates, just a thought
 
Last edited:

Bamse

Member
If you are running nginx on a separate machine from OBS, there's not much of a point trying to connect to localhost in OBS. alway use the other machines' IP.
Changing the $-variables won't enable you to connect to nginx, but if you don't change them nginx wont be able to get the streams since ffmpeg has no idea what that means and the whole transcode parts will fail. It will never end up with something that can be "push":ed to twitch.
You never mention if you use 720p as a stream key either, and using the same stream key parameter as the one specified in the first instance of the ffmpeg bat is very important.

But I'm not sure what to do from here on. I'm a Swede and my english is not the best and I've tried my best explaining what you need to do .. and by due to some reason those settings doesn't work for you in your setup. Just so you know where I'm coming from, I use the exact settings like I posted above in a few threads and it works for me when I try just when I'm typing this. I guess someone else will have to step up to the plate and take over and try to help you in a better way. Best of luck and take care! :)
 
Last edited:

Jack0r

The Helping Squad
OBS: use the IP of the pc you want to stream to if its not the PC running OBS.
so its rtmp://IP:Port/Appname. Then enter a streamkey like you did with 720p
Nginx config looked fine as far as I can see, apart of the one missing } at the end. So I will work with application transcode and live for ffmpeg.
FFmpeg: first IP is the address you used in OBS+Streamkey so rtmp://IP:Port/Appname/Streamkey. Probably rtmp://192.168.1.3/transcode/720p
second IP is the nginx again but this time the application that sends it to twitch so in your case: rtmp://192.168.1.3/live/blaBlub (blaBlub being an example streamkey).

So OBS streams to the transcode application in Nginx, ffmpeg takes that as input and sends it to the live application. Nginx then pushes it to twitch.
 

Bishops

New Member
jack0r i have tried all this, aslong as "transcode" is in OBS FML URL ill never be able to connect.... there has to be something... and yes guys i mentioned i tried many different playpath/stream keys, everytime i changed ip or anything i tried them all again, the first being 720p...
 

Jack0r

The Helping Squad
So FFmpeg gives you an error or what happens?
I thought you said OBS was able to connect and you could watch it with VLC? :)
 

Bishops

New Member
no i just can't connect to NGINX at ALL through OBS, unless i put rtmp://192.168.1.3/live, so far thats the ONLY time i have been able to connect to nginx succesfully and start uploading to it, but it obviously is skipping the encoding part, it dosen't even get push'd to twitch, nothing happens, no errors from ffmpeg or NGINX, just can't connect via OBS to "transcode"

and yes if i put rtmp://192.168.1.3/live into network stream on vlc ill be able to see the stream, but that is skipping the whole encoding part, i tried to do it that way and just capture VLC via another instance of OBS but as soon as i started the stream VLC started doing weird stuff
 

Bishops

New Member
yup tried it all over again, there is NOTHING i can do to get it to connect to NGINX "transcode" ONLY time i can connect to it is when i put rtmp://192.168.1.3/live

sadface

can i just trick it? since it will connect via "live" in OBS can i change the name of the transcode in nginx to "live" or something? someeeeeeething =(
 

Jack0r

The Helping Squad
Not really sure why that happens. I just made a simple config similar to yours, tried streaming to transcode with streamkey 720p works, playback with vlc sometimes needs one or two tries to work. Then streamed with obs to live, works fine too.
The config: https://gist.github.com/Jack0r/be82359316b6faeb82a1

My initial post was to make sure that you definitely set the exact ip/app/key everytime. There is no real trying, its just putting in the same values =) Does OBS give you an error like: "Could not connect to server - Try a different server" ?

Update: Tested ffmpeg with this commandline:
ffmpeg -re -i rtmp://192.168.0.3:1935/transcode/720p -vcodec libx264 -preset faster -x264opts nal-hrd=cbr:force-cfr=1:keyint=60 -r 60 -b:v 2000k -maxrate 2000k -bufsize 2000k -threads 12 -s hd720 -sws_flags spline -acodec copy -f flv rtmp://192.168.0.3:1935/live/720p
Works and playback from vlc works. Push should work as usual as long as ffmpeg produces a stream.
 
Top