Nginx rtmp module restream to a dynamic address

Viewed 143

some streams like:

rtmp://mysite:3939/app/aaaaaa;bbbb
rtmp://mysite:3939/app/wewewe;ffff
rtmp://mysite:3939/app/zeiwew;uuuu

comes to my nginx. i want restream them to these addresses:

rtmp://localhost:1935/app/aaaaaa
rtmp://localhost:1935/app/wewewe
rtmp://localhost:1935/app/zeiwew

i have this rtmp config, but i can not use map to make destination address. should i use $name variable? how? thanks for your help

rtmp {
    server {
        listen 3939;
        ping 30s;
        notify_method get;
        application app {
            live on;
            push rtmp://localhost:1935/app/;
        }
    }
}
1 Answers

There is a workaround, to use FFmpeg to pull and rename the stream:

ffmpeg -f flv -i rtmp://localhost:1935/app/bbbb \
  -c copy -f flv rtmp://localhost:1935/app/aaaaaa

Note: You could use the on_publish hook to start your FFmpeg process, or exec should also works.

It's very powerful pattern to process the stream, not only renaming the stream, but transcoding or forwarding to multiple servers, etc.

However it's a bit complex for introducing FFmpeg.

Related