Control module (original) (raw)

Control module is HTTP module which makes it possible to control rtmp module from outside using HTTP protocol. Here's an example of how to enable control.

http {
...
    server {
        listen       8080;
        server_name  localhost;
        ....
        location /control {
            rtmp_control all;
        }
     }
}

There are several sub-modules within control module each controlling a different feature.

Record

This sub-module starts and stops recordings created with manual flag. Syntax:

http://server.com/control/record/start|stop?srv=SRV&app=APP&name=NAME&rec=REC

Example

rtmp {
    server {
        listen 1935;
        application myapp {
            live on;
            recorder rec1 {
               record all manual;
               record_suffix all.flv;
               record_path /tmp/rec;
               record_unique on;
           }
       }
    }
}

Publish the stream with the following command

ffmpeg -i http://someserver.com/mychannel.ts -c:v copy -c:a nellymoser -ar 44100 -ac 1 -f flv rtmp://localhost/myapp/mystream

Use the following commands to start and stop recording

curl "http://localhost:8080/control/record/start?app=myapp&name=mystream&rec=rec1"
curl "http://localhost:8080/control/record/stop?app=myapp&name=mystream&rec=rec1"

if the record start/stop request returns nothing sometimes, you should check if you use multi workers. one worker works great.

Drop

This sub-module provides a simple way to drop client connection. Syntax:

http://server.com/control/drop/publisher|subscriber|client?
srv=SRV&app=APP&name=NAME&addr=ADDR&clientid=CLIENTID

The first method drop/publisher drops publisher connection. The second drop/client drops every connection matching addr argument or all clients (including publisher) if addr is not specified.

Examples

curl http://localhost:8080/control/drop/publisher?app=myapp&name=mystream
curl http://localhost:8080/control/drop/client?app=myapp&name=mystream
curl http://localhost:8080/control/drop/client?app=myapp&name=mystream&addr=192.168.0.1
curl http://localhost:8080/control/drop/client?app=myapp&name=mystream&clientid=1

Redirect

Redirect play/publish client to a new stream. Syntax:

http://server.com/control/redirect/publisher|subscriber|client?
srv=SRV&app=APP&name=NAME&addr=ADDR&clientid=CLIENTID&newname=NEWNAME

Add a custom footer