How to set up your own private RTMP server using nginx

All Versions How to set up your own private RTMP server using nginx

Jack0r

The Helping Squad
Greendweller said:
found out that if i use
record_suffix _%y-%m-%d--%T.mp4;
it crashes my nginx.exe.
Why i dont know (yet) but removing that line and leaving it on unique makes it work.
Guess its a syntax thingy linux vs win or something.

Its because %T outputs to HH:MM and : is not allowed in windows, replace it with this: %H-%M for example :)
On the rtmp-module wiki he links the page for the explanation http://pubs.opengroup.org/onlinepubs/00 ... ftime.html
 
Followed the tutorial and got this perfectly working with Twitch.tv (other than the fact that the quality pull-down on the Twitch player says "source", but thats not a big deal overall for me). Now I am trying to also get it to stream to UStream, but I am not having any luck.

The line is just like the one for TWITCH, "push rtmp://<url>/<key>;" The URL is a direct copy and past from the UStream dashboard, as is the key, and everything looks correct, but it just wont broadcast. If I have twitch and ustream players open side by side, press broadcast, Twitch starts playing soon after, but UStream does not.
 
I double checked to make sure that UStream wasn't preventing the stream due to the resolution, since I broadcast at 720P, but my basic UStream account only supports up to 480P. That wasnt it, since OBS broadcasted to UStream directly with the 720P source. Can only assume that UStream does not like the URL format I am using with nginx (rtmp://<url>/<key>).

Does anyone know the proper URL format to use to stream to UStream? Again, Twitch accepts the above URL/Key format. I have been unable to find, via google, any pages that show how to format it for UStream.
 

dodgepong

Administrator
Forum Admin
Updated the guide a bit, removing stuff about nginx 1.2.7 and replacing rtmpdump info with VLC 2.1.0 info.

I also hope to either expand this guide, or make another guide showing people how do to things like transcoding, HLS, and recording.

Thanks to everyone for feedback on this guide so far. I'm glad it helps!
 

Kashimus

New Member
I hope someone could help me, i'm looking for a method which would allow me to rewind my own stream, not only it would play the live video but you could start from the beggining like i saw it on e3's stream where you could search the stream,like rewind where you left it and the watch it from that point and of you want to resume wathcing the live show with one click.
so which player is capable of doing this (i was looking at flowplayer opensource-and moddable),and what i need configure on my own rtmp server (ngix) to do this if it possible.

i'm looking for the methods how can i do it,on my own vps, and what extra stuff i need like extra storage etc.
I hope its understandable
 

dodgepong

Administrator
Forum Admin
You would need a server that uses HLS to transmit data and a player that supports DVR functionality. I believe the paid version of JWPlayer might support HLS DVR, but I'm not sure if that feature is released yet (apparently part of JWPlayer 6.6: http://developer.longtailvideo.com/trac/ticket/1644).

So if you wanted to use nginx to deliver HLS, you'll need to set it to transcode your uploaded stream to HLS, too. I'd like to have a guide for how to do this but I haven't had the time yet.
 

Kashimus

New Member
Thanks for the reply, now i know what feautures/functions i need,for this project.

One more question ,can i delay my stream with ngix,and can i manupulate the volume level, on the stream with ngix?
 

Yamato64

New Member
Hello,
I'm in trouble :
I had a contract for a small VPS and it ran out before i could renew it. So i had to suscribe again, to the exact same service, with the same build : Ubuntu 12.04 64bits server.
I have exactly the same nginx.conf file, and i did follow the tutorial like the first time.

Nginx is up and running, pushing my stream to two providers like before, but now i don't have transcoding either on Twitch or Dailymotion.
If i stream directly to these server, transcoding is okay, so i definitely think there's something fishy in Nginx, but i can't figure it out.

Here is my conf :

application XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX {
live on;
interleave on;
meta off;
publish_notify on;
wait_key on;
wait_video on;
push rtmp://publish.dailymotion.com/publish- ... XXXXXXXXXX live=1;
push rtmp://live-lhr.twitch.tv/app/XXXXXXXXX ... XXXXXXXXX;
}

Meta have always been off because I couldn't get transcode with dailymotion while it was on. Trying to put Meta on and i get back transcoding on Twitch, but not on Dailymotion.

I really don't know where it could come from, help much appreciated, thank you very much
 
anyone have any suggestions for how to get Nginx+rtmp to stream to UStream? The URL+stream key combination just doesnt seem to want to work in the "push" line of code. The URL and key are direct copy and pastes, I just dont think it is formatted right. Copying and pasting the URL and key separately directly into OBS, however, does work.

here is the rtmp portion of my nginx config, with sections redacted with XXXXX

This config streams to both Twitch.tv and Hashd.tv with no problems. I created a number of different push URLs for UStream, one based on the Twitch config, another based on the Hashd config, and another with the key variable replaced with stream just to test it out. None of the 3 work. I have to be missing something here but I just cannot find any forums or articles online with a solid ustream rtmp url/key combo to work with.

Code:
rtmp {
	server {
		listen XXXXX;
		chunk_size 4086;
		
		application live {
			live on;
			push_reconnect 5s;
			#access_log /var/my_records/logs/rtmp_access.log;
			
			interleave on;
			meta on;
			publish_notify on;
			wait_key on;
			wait_video on;
			
			recorder audio {
				record audio;
				record_unique on;
				record_path XXXXX;
				record_suffix .audio.flv;
			}
			
			recorder chunked {
				record all;
				record_unique on;
				record_interval 240m;
				record_path XXXXX;
			}
			
			
			
			
			# Nearest Twitch Ingest Server (NYC) to Interserver VPS (New Jersey)
			push "rtmp://live-jfk.twitch.tv/app/XXXXXXX";
			
			
			# YouTube Live   # push rtmp://  ;
			
			
			# HASHD.TV       #
			push "rtmp://ingest-dal1.hashd.tv/live/XXXXXX?key=XXXXXX";
			
			
			# USTREAM.TV     #  Note to forum readers.  None of the following work...
			push rtmp://1.XXXXXXXX.fme.ustream.tv/ustreamVideo/XXXXXXXX/XXXXXXXX;
			# push rtmp://1.XXXXXXXX.fme.ustream.tv/ustreamVideo/XXXXXXXX/?key=XXXXXXXX;
			# push rtmp://1.XXXXXXXX.fme.ustream.tv/ustreamVideo/XXXXXXXX/?stream=XXXXXXXX;
		}
	}
}

any help would be much appreciated
 

dodgepong

Administrator
Forum Admin
What version of nginx-rtmp-module are you using? The latest version (1.0.4, just released) added metadata copying, and I wonder if UStream rejects streams with incomplete metadata. (More info here: http://nginx-rtmp.blogspot.com/2013/09/ ... odule.html)

It's kind of a shot in the dark...when I get a chance, I'll try to play around with UStream myself (I've never actually streamed there before).
 
i believe i am running 1.0.3, as I installed it based on the guide in this forum post, and only installed it within the last 2 weeks.


ill backup my config files and do a recompile in the morning and see if that fixes things.
 
well I did the recompile with the latest rtmp module, set it up using "meta copy", but it is still unable to broadcast to UStream. On a side note, I do have it set up to broadcast to YouTube Live, Twitch and Hashd.tv successfully at the same time.
 

DrDos

New Member
So I've managed to get this working great. No issues with streaming to my server, and nobody has had any problems watching the stream.

The only thing I'm wondering now is how to restrict access on streaming. The play path/stream key value which I would assume would be the security seems to be needed by the javascript for the stream viewing page. Am I missing something somewhere?

I know I can restrict by IP in nginx's config, but that seems like a hassle with a non-static IP at home.
 

tdx3000

New Member
First thank you for the great tutorial, it was easy to followed.

However i have two issues i need help on.

1. I follow another member guide on how to play it with JWPlayer, it work locally (on the same network) but i can't view it over the web. router already forward ports to nginx-rtmp server.

I was able to play it over the internet with rtmpdump + vlc

2. when i play over the internet with rtmpdump+vlc video play for 4,5 seconds then freeze for 1,2 second. My upload speed is was faster then the stream required.
 

MarkKing

New Member
Re: Simple Website with JWplayer

jhn123 said:
I have a similar setup like Steveswl with VirtualBox. I've created a simple website that will center JWplayer. Using some CSS, I made JWplayer responsive so it will adjust the size according to your browser.

How can I use this stream in JWplayer on a joomla website (not local)? I tried using the main IP address but it never connects. Please help!
 

tdx3000

New Member
Code:
<div id="myElement">Loading the player...</div>      
    <script type="text/javascript">
        jwplayer("myElement").setup({
		file: "rtmp://ip.address/live/teststream",
		height: 480,
		width: 720
		});
    </script>

if i load that on another computer locally (same network) it play fine but over the internet NO. I already forward port 1935 tcp to nginx-rtmp server already.

degepong any chance you will have guide to set up with authentication soon ? just asking :D

I've been searching for a guide to start nginx automatically after boot but still no success, i follow this guide http://articles.slicehost.com/2007/10/1 ... nit-script

Thanks
 

MarkKing

New Member
dodgepong said:
All you have to do is give JWPlayer the RTMP URL + key. So If you're streaming to rtmp://your.server/live with a stream key of "streamkey", then JWPlayer would need to be pointed at rtmp://your.server/live/streamkey

Note that this isn't terribly secure.

Thank you for your reply, dodgepong. It seems like tdx & I are having the same issue. My stream plays fine locally as well as outside my home network when I try to stream it via MX player but for some reason I can't get JWplayer to play the stream. Here's what I currently have:

Code:
<script src="http://jwpsrv.com/library/YOUR_JW_PLAYER_ACCOUNT_TOKEN.js" 
></script>
<div id="myElement">Loading the player ...</div>
<script type="text/javascript" src="/scripts/jwplayer.js" ></script>
<script type="text/javascript">jwplayer.</script>
<script type="text/javascript">
   jwplayer("myElement").setup({
    file: "rtmp://my.ip.address/live/my.key",
    image: "/assets/myVideo.jpg",
    height: 360,
    width: 640
});
</script>

This is the error msg I get from JW player on my site: 'There was an error retrieving your embed.
Please double check your hosted URL in your JW Dashboard'.

What am I doing wrong? I followed JWplayer's guide here: http://www.longtailvideo.com/support/jw ... -streaming
 

dodgepong

Administrator
Forum Admin
Are you sure the IP address you're using for the server is the external IP and not the internal IP?
 
Top