网站首页 > 博客文章 正文
前言
使用 Nginx + Nginx-rtmp-module 在Ubuntu 中搭建简单的 rtmp 推流直播服务器。
服务器环境
Ubuntu 16.04
相关概念
- RTMP: RTMP协议是Real Time Message Protocol(实时信息传输协议)的缩写,它是由Adobe公司提出的一种应用层的协议。依赖于flash播发器来拉流。
请求样式:rtmp://xxx.xxx.xxx.xxx:1935/ttest(命名空间)/test(推流码)
- HLS:苹果出的一套Http Live Streaming协议,它的工作原理简单来说就是把一段视频流,分成一个个小的基于HTTP的文件来下载。通过读取.m3u8文件读取一个一个的视频流片段。
请求样式:http://xxx.xxx.xxx.xxx/video(nginx配置路由)/test.m3u8
- nginx-rtmp-module: 基于Nginx的流媒体Server
测试工具
1. 推流工具:易推流(ios)
2.拉流工具:VLC media player(pc)
实现步骤
一、安装或升级Nginx
sudo apt-get install software-properties-common python-software-properties
sudo add-apt-repository ppa:nginx/stable
sudo apt-get update
sudo apt-get install nginx
二、安装nginx-rtmp-module
sudo apt-get install libnginx-mod-rtmp
三、编写nginx配置
1. /etc/nginx/nginx.conf
user ubuntu;
rtmp{
server{
listen 1935;
chunk_size 4000;
application test{
live on;
record off;
hls on;
hls_path /usr/local/src/nginx/html/test;
hls_fragment 1s;
hls_playlist_length 3s;
}
}
}
2. /etc/nginx/sites-enables/default
location /video/ {
alias /usr/local/src/nginx/html/godeyeTest/;
# 余下三行配置是解决跨域问题
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods 'GET, POST, OPTIONS';
add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
}
四、新建路径,重启nginx服务
1. mkdir 配置中的路径(/usr/local/src/nginx/html/test)
2. serive nginx restart
猜你喜欢
- 2024-10-05 Nginx + FastCGI 程序(C/C++) 搭建高性能web service
- 2024-10-05 Docker使用Nginx制作静态文件服务器
- 2024-10-05 使用nginx将服务器升级为https(nginx代理服务器配置)
- 2024-10-05 vue项目打包后部署到nginx(vue打包 nginx)
- 2024-10-05 Nginx Windows详细安装部署教程(nginx安装及配置教程)
- 2024-10-05 Vue实战091:Vue项目部署到nginx服务器
- 2024-10-05 Zabbix4.0企业级搭建实战(1)LNMP之Nginx服务器编译安装
- 2024-10-05 Linux上安装Nginx服务器(linux安装nginx详细步骤)
- 2024-10-05 Nginx 整合 FastDFS 实现文件服务器
- 2024-10-05 Linux中如何简单快速安装nginx以及如何配置
你 发表评论:
欢迎- 最近发表
- 标签列表
-
- ifneq (61)
- 字符串长度在线 (61)
- googlecloud (64)
- messagesource (56)
- promise.race (63)
- 2019cad序列号和密钥激活码 (62)
- window.performance (66)
- qt删除文件夹 (72)
- mysqlcaching_sha2_password (64)
- ubuntu升级gcc (58)
- nacos启动失败 (64)
- ssh-add (70)
- jwt漏洞 (58)
- macos14下载 (58)
- yarnnode (62)
- abstractqueuedsynchronizer (64)
- source~/.bashrc没有那个文件或目录 (65)
- springboot整合activiti工作流 (70)
- jmeter插件下载 (61)
- 抓包分析 (60)
- idea创建mavenweb项目 (65)
- vue回到顶部 (57)
- qcombobox样式表 (68)
- tomcatundertow (58)
- pastemac (61)
本文暂时没有评论,来添加一个吧(●'◡'●)