|
1 | | -# NGINX-based Media Streaming Server |
| 1 | +- [Pingos Media Streaming Server](#pingos-media-streaming-server) |
| 2 | + - [nginx-rtmp-module](#nginx-rtmp-module) |
| 3 | + - [项目博客](#项目博客) |
| 4 | + - [QQ交流群: 697773082](#qq交流群-697773082) |
| 5 | +- [服务器介绍](#服务器介绍) |
| 6 | + - [服务器功能](#服务器功能) |
| 7 | + - [我所做的改进](#我所做的改进) |
| 8 | +- [搭建流程](#搭建流程) |
| 9 | + - [编译过程](#编译过程) |
| 10 | + - [环境](#环境) |
| 11 | + - [安装依赖](#安装依赖) |
| 12 | + - [安装](#安装) |
| 13 | + - [配置文件](#配置文件) |
| 14 | + - [修改配置](#修改配置) |
| 15 | + - [配置模板(此配置能够满足单点服务)](#配置模板此配置能够满足单点服务) |
| 16 | + - [开启流监控页面](#开启流监控页面) |
| 17 | + - [启动nginx](#启动nginx) |
| 18 | + - [注意事项](#注意事项) |
| 19 | + - [推流](#推流) |
| 20 | + - [后台监控](#后台监控) |
| 21 | +- [全局配置](#全局配置) |
| 22 | +- [rtmp服务配置](#rtmp服务配置) |
| 23 | +- [http-flv配置](#http-flv配置) |
| 24 | +- [http-ts服务配置](#http-ts服务配置) |
| 25 | +- [hls服务配置](#hls服务配置) |
| 26 | +- [录像服务](#录像服务) |
| 27 | +- [http控制接口](#http控制接口) |
| 28 | + - [配置说明](#配置说明) |
| 29 | + - [控制接口说明](#控制接口说明) |
| 30 | + - [配置模板](#配置模板) |
| 31 | + |
| 32 | + |
| 33 | +# Pingos Media Streaming Server |
2 | 34 | ## nginx-rtmp-module |
3 | 35 |
|
4 | 36 | ### 项目博客 |
5 | 37 |
|
6 | 38 | * https://blog.csdn.net/impingo |
7 | 39 |
|
8 | 40 | * http://pingos.me |
9 | | -* QQ交流群:流媒体人的后院(697773082) |
| 41 | + |
| 42 | +### QQ交流群: 697773082 |
10 | 43 |
|
11 | 44 | # 服务器介绍 |
12 | 45 |
|
@@ -257,15 +290,37 @@ rtmp推流地址:rtmp://ip/live1/stream-name |
257 | 290 |
|
258 | 291 | 通过这个配置你可以实现自定义的location名字,无需跟application名保持一致。 |
259 | 292 | ```nginx |
| 293 | +user root; |
| 294 | +daemon on; |
| 295 | +master_process on; |
| 296 | +worker_processes 1; |
| 297 | +#worker_rlimit 4g; |
| 298 | +#working_directory /usr/local/openresty/nginx/logs; |
| 299 | + |
| 300 | +#error_log logs/error.log; |
| 301 | +#error_log logs/error.log notice; |
| 302 | +error_log logs/error.log info; |
| 303 | + |
| 304 | +worker_rlimit_nofile 102400; |
| 305 | +worker_rlimit_core 2G; |
| 306 | +working_directory /tmp; |
| 307 | + |
| 308 | +#pid logs/nginx.pid; |
| 309 | + |
| 310 | +events { |
| 311 | + worker_connections 1024; |
| 312 | +} |
| 313 | +stream_zone buckets=1024 streams=4096; |
| 314 | + |
260 | 315 | rtmp { |
261 | 316 | server { |
262 | 317 | listen 1935; |
263 | 318 | application live0 { |
264 | 319 | live on; |
265 | | -} |
266 | | -application live1 { |
267 | | - live on; |
268 | | -} |
| 320 | +} |
| 321 | +application live1 { |
| 322 | + live on; |
| 323 | +} |
269 | 324 | } |
270 | 325 | } |
271 | 326 | |
@@ -297,15 +352,37 @@ rtmp推流地址:rtmp://ip/live1/stream-name |
297 | 352 | 对应的http-ts播放地址:http://ip/live1/stream-name 和 http://ip/ts1/stream-name |
298 | 353 |
|
299 | 354 | ```nginx |
| 355 | +user root; |
| 356 | +daemon on; |
| 357 | +master_process on; |
| 358 | +worker_processes 1; |
| 359 | +#worker_rlimit 4g; |
| 360 | +#working_directory /usr/local/openresty/nginx/logs; |
| 361 | + |
| 362 | +#error_log logs/error.log; |
| 363 | +#error_log logs/error.log notice; |
| 364 | +error_log logs/error.log info; |
| 365 | + |
| 366 | +worker_rlimit_nofile 102400; |
| 367 | +worker_rlimit_core 2G; |
| 368 | +working_directory /tmp; |
| 369 | + |
| 370 | +#pid logs/nginx.pid; |
| 371 | + |
| 372 | +events { |
| 373 | + worker_connections 1024; |
| 374 | +} |
| 375 | +stream_zone buckets=1024 streams=4096; |
| 376 | + |
300 | 377 | rtmp { |
301 | 378 | server { |
302 | 379 | listen 1935; |
303 | 380 | application live0 { |
304 | 381 | live on; |
305 | | -} |
306 | | -application live1 { |
307 | | - live on; |
308 | | -} |
| 382 | +} |
| 383 | +application live1 { |
| 384 | + live on; |
| 385 | +} |
309 | 386 | } |
310 | 387 | } |
311 | 388 | |
@@ -358,3 +435,66 @@ http { |
358 | 435 | | live_record_min_fragment | 时间 | 8000ms | 录制过程中索引文件里记录的最小分片大小 | |
359 | 436 | | live_record_max_fragment | 时间 | 12000ms | 录制过程中索引文件里记录的最大分片大小 | |
360 | 437 | | live_record_buffer | 整型数 | 1024*1024 | 录制过程中数据缓冲大小 | |
| 438 | + |
| 439 | +# http控制接口 |
| 440 | +## 配置说明 |
| 441 | +| 配置项 | 参数类型 | 默认值 | 描述 | |
| 442 | +|--|--|--|--| |
| 443 | +| rtmp_control | 选项 | all | all: 开启所有控制接口。record: 只开启录像控制接口。drop:只开启关闭连接控制接口。redirect:只开启重定向控制接口。pause:只开启暂停接口。 resume:只开启恢复接口 | |
| 444 | + |
| 445 | + |
| 446 | +## 控制接口说明 |
| 447 | + |
| 448 | +| 接口名 | 请求 | 回复 | 描述 | |
| 449 | +|--|--|--|--| |
| 450 | +| 暂停推流 | /\${location}/pause/publisher?srv=\${serverid}&app=\${app}&name=\${name} | 参考 http ack | 服务器停止转发收到的直播流 | |
| 451 | +| 恢复推流 | /\${location}/resume/publisher?srv=\${serverid}&app=\${app}&name=\${name} | 参考 http ack | 服务器恢复转发收到的直播流 | |
| 452 | +| 暂停录像 | /\${location}/record/stop?srv=\${serverid}&app=\${app}&name=\${name}&rec=\${recorder} | 参考 http ack | 暂停某条流的录像 | |
| 453 | +| 恢复录像 | /\${location}/record/start?srv=\${serverid}&app=\${app}&name=\${name}&rec=\${recorder} | 参考 http ack | 恢复某条流的录像 | |
| 454 | + |
| 455 | +## 配置模板 |
| 456 | +```nginx |
| 457 | +user root; |
| 458 | +daemon on; |
| 459 | +master_process on; |
| 460 | +worker_processes 1; |
| 461 | +#worker_rlimit 4g; |
| 462 | +#working_directory /usr/local/openresty/nginx/logs; |
| 463 | + |
| 464 | +#error_log logs/error.log; |
| 465 | +#error_log logs/error.log notice; |
| 466 | +error_log logs/error.log info; |
| 467 | + |
| 468 | +worker_rlimit_nofile 102400; |
| 469 | +worker_rlimit_core 2G; |
| 470 | +working_directory /tmp; |
| 471 | + |
| 472 | +#pid logs/nginx.pid; |
| 473 | + |
| 474 | +events { |
| 475 | + worker_connections 1024; |
| 476 | +} |
| 477 | +stream_zone buckets=1024 streams=4096; |
| 478 | + |
| 479 | +rtmp { |
| 480 | + server { |
| 481 | + listen 1935; |
| 482 | + application live { |
| 483 | + live on; |
| 484 | + recorder rc0 { |
| 485 | + record all; |
| 486 | + record_path /tmp; |
| 487 | + } |
| 488 | + } |
| 489 | + } |
| 490 | +} |
| 491 | + |
| 492 | +http { |
| 493 | + server { |
| 494 | + listen 80; |
| 495 | + location control { |
| 496 | + rtmp_control all; |
| 497 | + } |
| 498 | + } |
| 499 | +} |
| 500 | +``` |
0 commit comments