nginx实现最简单的直播
系统环境
[root@yunwei-test live]# cat /etc/redhat-release
CentOS Linux release 7.3. (Core)
[root@yunwei-test live]# getenforce
Disabled
root@yunwei-test live]# systemctl stop firewalld
[root@yunwei-test live]# hostname -I
10.0.3.56
1、git拉取nginx-rtmp插件
mkdir -p /server/tools cd /server/tools git clone https://github.com/arut/nginx-rtmp-module.git
2、编译安装nginx
[root@yunwei-test tools]# useradd -s /sbin/nologin -M nginx
[root@yunwei-test tools]# wget http://nginx.org/download/nginx-1.14.0.tar.gz
[root@yunwei-test tools]# tar xf nginx-1.14..tar.gz
[root@yunwei-test tools]# cd nginx-1.14./
[root@yunwei-test nginx-1.14.]# yum install pcre-devel openssl-devel.x86_64 -y
[root@yunwei-test nginx-1.14.]# ./configure --user=nginx --group=nginx --with-http_ssl_module --prefix=/application/nginx --add-module=../nginx-rtmp-module #rtmp模块的路径
[root@yunwei-test nginx-1.14.]# make && make install
3、配置启动nginx
cd /application/nginx/conf/
grep -Ev '^$|#' nginx.conf.default >nginx.conf
vim nginx.conf
worker_processes ; events { worker_connections ; } rtmp { server { listen ; chunk_size ; application live { live on; hls on; hls_path /application/nginx/html/live; hls_fragment 5s; } } } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout ; server { listen ; server_name localhost; location /live { types { application/vnd.apple.mpegurl m3u8; video/mp2t ts; } alias /application/nginx/html/live; expires -; add_header Cache-Control no-cache; } location / { root html; index index.html index.htm; } } } #测试nginx语法 ../sbin/nginx –t 启动nginx ../sbin/nginx
4、使用EV录屏实现推流
串流地址: rtmp://10.0.3.56:1935/live
地址密钥随便填,我这里是test
如果你的地址密钥填写和一样的话,
开启直播之后,测试能否下载test.m3u8文件
http://10.0.3.56/live/test.m3u8
如果能够成功下载,恭喜你离成功很近了!
5、配置站点首页
vi /application/nginx/html/index.html <!DOCTYPE html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title>前端播放m3u8格式视频</title> <link rel="stylesheet" href="http://vjs.zencdn.net/5.5.3/video-js.css"> <script src="http://vjs.zencdn.net/5.5.3/video.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/videojs-contrib-hls/5.12.2/videojs-contrib-hls.js"></script> </head> <body> <video id="myVideo" class="video-js vjs-default-skin vjs-big-play-centered" controls preload="auto" width="" height="" data-setup='{}'> <source id="source" src="http://10.0.3.56/live/test.m3u8" type="application/x-mpegURL"> </video> </body> <script> // videojs 简单使用 var myVideo = videojs('myVideo',{ bigPlayButton : true, textTrackDisplay : false, posterImage: false, errorDisplay : false, }) myVideo.play() // 视频播放 myVideo.pause() // 视频暂停 </script> </html>
打开浏览器测试:
http://10.0.3.56
直播技术的原理,可以参考文章https://blog.csdn.net/leifukes/article/details/73244012
nginx实现最简单的直播的更多相关文章
- 极速搭建RTMP直播流服务器+webapp (vue) 简单实现直播效果
在尝试使用webRTC实现webapp直播失败后,转移思路开始另外寻找可行的解决方案.在网页上尝试使用webRTC实现视频的直播与看直播,在谷歌浏览器以及safari浏览器上测试是可行的.但是基于基座 ...
- (转载)学校搭建使用nginx同时编译rtmp-module进行直播的技术文档
原文地址:学校搭建使用 nginx 同时编译 rtmp-module 进行直播的技术文档 转载自我的大佬同学 MetalkgLZH.学校有几次需要全校观看网络直播的情况,但是学校的带宽不允许所有的班一 ...
- nginx负载均衡简单配置
nginx负载均衡简单配置准备三台虚拟机来做这个实验:192.168.232.132 web服务器192.168.232.133 web服务器192.168.232.134 ...
- Linux笔记 #09# Tomcat多开以及Nginx负载均衡简单例子
索引 Tomcat怎样多开.. 1.添加环境变量(最基础.关键的步骤!) 2.改catalina.sh 3.改相关端口 Nginx负载均衡简单例子 Tomcat怎样多开.. 演示一下如何开两个(开n个 ...
- window 平台搭建简单的直播点播系统
Windows平台如何搭建简单的直播系统前文已经有介绍,今天介绍下如何搭建简单的点播系统. 同样还是利用crtmpServer,crtmpServer可以从github中下载,可以从群里下载(群里有修 ...
- 通过Nginx实现一个简单的网站维护通知页面
原文:https://www.zhyd.me/article/106 在网站发版时,总会有那么一小段时间服务是访问不通的,一般用户看到的都会是一个502的错误页面 那么可以通过nginx实现一个简单的 ...
- nginx动静分离简单实例实现
什么是动静分离? Nginx 动静分离简单来说就是把动态和静态请求分开,不能理解成只是将动态页面和静态页面物理分离.严格意义上说应该是动态请求和静态请求分开,可以理解成使用 nginx 处理静态页面, ...
- Nginx 推流 拉流 --- 点播直播
1. 准备环境 安装操作系统Cenos 配置yum源 yum:https://developer.aliyun.com/mirror/ Nginx依赖 gcc-c++ zlib pcre openss ...
- Nginx|构建简单的文件服务器(mac) 续-FastDFS安装(mac)|文件存储方案
目录 Nginx|构建简单的文件服务器(mac) 1 所需安装包 2 安装fastdfs-nginx-module-master 3 安装Nginx Nginx|构建简单的文件服务器(mac) 续上文 ...
随机推荐
- BSD介绍
BSD许可证模板 * Copyright (c) 1998, Regents of the University of California * All rights reserved. * ...
- mac系统下虚拟机parallels安装ubuntu 14.04
mac系统很棒,mac下的开发环境也很棒,但有时你还得需要ubuntu开发环境,比如进行嵌入式Linux交叉编译,使用Linaro toolchain… 其实mac系统下使用parallels虚拟机安 ...
- swift4.0 Http 请求
// // HttpHelper.swift // NavigateDemo // // Created by yixin ran on 07/08/2017. // Copyright © 2017 ...
- 【转】 C#后台调用前台javascript的五种方法
第一种,OnClientClick (vs2003不支持这个方法)<asp:ButtonID="Button1" runat="server" Te ...
- Android项目实战(一): SpannableString与SpannableStringBuilder
原文:Android项目实战(一): SpannableString与SpannableStringBuilder 前言: 曾经在一些APP中的一些类似“帮助”“关于”的界面看过一行文字显示不同的颜色 ...
- 2018-4-25 1.如何在GitHub上新建一个新的项目并下载该项目及如何提交新的文件
- 网络流量查看工具为 iftop
作者: daodaoliang 时间: 2016年5月23日 版本: v0.0.1 邮箱: daodaoliang@yeah.net 日常用的网络流量查看工具为 iftop, 但是他仅仅只能简单的查看 ...
- iOS学习总结之ARC和非ARC的单例模式实现
iOS单例模式的实现 首先我们要明白下面三个问题: 什么是单例模式 单例模式的优点 如何实现单例模式 1.什么是单例模式 单例模式(Singleton):单例模式确保对于一个给定的类只有一个实例存在, ...
- 使用Notepad++远程编辑Ubuntu上的源码
简单搭建了在Windows上远程编辑Ubuntu Server 14.04上面源代码的环境,记录一下,给需要的人. Notepad++安装NppFTP 从插件菜单打开PluginManager,选中N ...
- SQL Server 2008收缩日志文件--dbcc shrinkfile参数说明
原文:SQL Server 2008收缩日志文件--dbcc shrinkfile参数说明 DBCC SHRINKFILE 收缩相关数据库的指定数据文件或日志文件大小. 语法 DBCC SHRINKF ...