All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
nginx-rtmp setup help
I am working on a project to stream a small amount of videos.
I have setup nginx-rtmp and am able to stream from my vod application using jwplayer.
the video is an .mp4 file
In jwplayer file: "rtmp://my.site:1935/vod/mp4:video.mp4",
works to stream the vod video.
in vlc i can load the stream with
rtmp://my.site:1935/vod/video.mp4
Im trying to authenticate or secure the stream using nginx-rtmp-auth
https://github.com/Nesseref/nginx-rtmp-auth
Now this is where it seems to cause an issue.
There is little to no docs for the auth scripts and i can register a user and generate a hash but it never authenticates the stream for me?
When i create a user in the auth script it gives me a hash
rtmp://my.site:1935/vod/video.mp4?58a62884193a43e2a5ab
entering this url into VLC throws an error where before it did allow me to load the video
Here is my nginx.conf
rtmp {
server {
listen 1935;
chunk_size 4096;
application stream {
live on;
record off;
on_publish http://my.site/auth.php;
notify_method get;
}
}
}
I have only added the on_publish and notify_method lines, commenting them out allows me to stream the video again.
Anyone have experience with this kind of setup?
What is the best way to secure the stream for these videos?
Comments
what kind of error? Make sure that you can wget http://my.site/auth.php inside your server and no error occur.
Btw, it's better if you change your publish url to something else (like stream-secret, and change your port to #random number), and limit your "stream" to local publish only, then copy the stream from the "stream-secret" to "stream".
If you have static IP (or dynamic IP range), set allow_publish for stream-secret to that IP will ensure maximum privacy.
@ihatetonyy might have a clue. he told me before there is some hack for securing nginx rtmp.
btw, why use rtmp? why not hls?
I agree that HLS or DASH might be better, maybe he just needs to have a delay-free stream. Also HLS and/or DASH needs some more work to setup, since NGINX RTMP isn't actively developed anymore.
the videos he is mentioning seems pre-rendered and not live. so maybe just convert mp4 to m3u8 using ffmpeg and serve as static files. no need to convert to rtmp on the fly, just pure static on any webserver. then maybe have a php code or something to protect the files using some programming trick. no need to work with complex config with rtmp module.
You are right, he is just using live on; in his config which got me confused.
Sorry i pasted the wrong config!
I am using VOD and on_play to stream some videos to users
rtmp {
server {
listen 1935;
chunk_size 4096;
}
I am using on_play and all the setup is basically default so i can test before i move to a live setup.
I looked into HLS and DASH but wasnt sure i need it to just stream a few videos on Demand.
The source video files are x264 mp4 format
I can get it to stream from the rtmp server using jwplayer but am now trying to authenticate the stream when a user plays the vod video.
sorry for the confusion trying to wrap my head around using nginx-rtmp for the first time
So your end goal is streaming of live events? I may also need this. I will experiment in the near future. If I find anything, I will try to let you know
Follow this config:
Then, create the "auth.php" page like below and put it in a server:
It's ready. Now, you have to put your password to your stream's url in FMLE or wherever:
rtmp://serverip/live/stream?passphrase=PUTYOURPASSWORDHERE
@jcaleb my end goal is to serve up training videos but only for paying students so i need a way to auth the streams
@jvnadr thanks will this work if i use on_play instead of on_publish?
rtmp {
server {
listen 1935;
chunk_size 4096;
}
another nginx module for HLS and DASH i found:
https://github.com/kaltura/nginx-vod-module
Yes, it will, but you have to add ?passphrase=xxx to the end of your desired stream file. Although, I do not see the usage when nginx-rtmp will play on demand files from your server...
I see. So it is not live. Then it should be easy. I don't think you even need rtmp module for this. Just wrap the files with php, Java, or whatever language you are using.
For example, you have training1.mp4. Convert it to hls. So you will have training1.m3u8 plus a bunch of *.ts.
You can put these files outside the web content.
Then write a code that will serve static files. http://mydomain.com/servefiles.php?training1.m3u8
servefiles.php will check if your using have purchased training1.m3u8 via db quesries. If yes, then let this php code read training1.m3u8 and push the byte stream to the user.
Agreed, for VOD (as opposed to live streaming), you don't need nginx-rtmp; ffmpeg can do the HLS segmentation and any desired transcoding. Put it in a batch script that runs nightly over newly uploaded videos.
For live streaming, the three nginx solutions I had found were nginx-rtmp, nginx-vod, and nginx's own commercial nginx-hls module.