rtmp_control
all: 开启所有控制接口。
record: 只开启录像控制接口。
drop: 只开启关闭连接控制接口。
redirect:只开启重定向控制接口。
pause: 只开启暂停接口。
resume:只开启恢复接口。
rtmp {
server {
application camera {
live on;
recorder all {
record all manual; //不自动启动录制,使用控制接口来启动/停止
record_suffix -%Y-%m-%d-%H_%M_%S.flv;
record_path /tmp;
}
}
}
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upload_progress proxied 8m;
upload_progress_json_output;
server {
listen 80;
server_name localhost;
location /control { //加入控制模块
rtmp_control all;
}
}
}
JS控制触发录制的开始/停止
var IP = window.location.hostname; //获取本地IP地址
//开始
$("#LAY-record-start-button-submit").click(function () {
var url = 'http://'+ IP +'/control/record/start?app=camera&name=video0&rec=all';
var request = new XMLHttpRequest();
request.open("Get", url, true);
request.send()
});
//停止
$("#LAY-record-stop-button-submit").click(function () {
var url = 'http://' + IP + '/control/record/stop?app=camera&name=video0&rec=all';
var request = new XMLHttpRequest();
request.open("Get", url, true);
request.send()
});
url内容简述:
与nginx-rtmp模块配置文件对应:
app=camera -------- application camera
rec=all -------- recorder all
name=video0 //自定义命名