arut / nginx-rtmp-module

NGINX-based Media Streaming Server
http://nginx-rtmp.blogspot.com
BSD 2-Clause "Simplified" License
13.35k stars 3.51k forks source link

Change stream name after on_publish call #713

Open zerogee00 opened 8 years ago

zerogee00 commented 8 years ago

I have a system setup where publishers get a streamkey (lets say abc123) from my api and are able to stream to an app named 'stream' where it creates HLS playlist and TS files. (abc123.m3u8, etc) They point their encoders to rtmp://streaming.server.com/stream/abc123

Then via on_publish it calls an 'authentication application' that checks if that streamkey is in our api and then returns 200 if it is and 4xx if it isn't. It can also look up a more public key (xyz789) at this point (but how would I return that key to the rtmp module?)

What I then need to be able to do it somehow change the stream name to that public key and have the files named xyz789.m3u8 etc so that only the publisher and not any clients know the original streamkey and can watch the stream via http://streaming.server.com/stream*/xyz789.m3u8

*or another redirected app

zerogee00 commented 8 years ago

Any ideas?

cccaochao commented 8 years ago

you could rewrite rtmp URL or stream name by set on_publish .

misiek08 commented 8 years ago

on_publish notify event allows you to change stream name by setting Location header to desired value in response.

zerogee00 commented 8 years ago

Do I need to return a 300 for it to redirect properly? Also do I need to have separate app or can it be the same app with just new stream name?

cccaochao commented 8 years ago

@zerogee00 you are right.

misiek08 commented 8 years ago

Any 3xx code should work. You don't need separate app. You can handle it in your script and if you return 200 code without Location header nginx won't change name, so you can change name only for some publishers.

zerogee00 commented 8 years ago

Thanks everybody - this worked great I am changing the name by setting location in the header and returning 300.

headbutt commented 8 years ago

I have the same problem, but it doesn't change the directory name it remains the same.