ICode9

精准搜索请尝试: 精确搜索
首页 > 系统相关> 文章详细

音视频系列--ubuntu+nginx搭建流媒体服务器

2021-01-17 17:32:18  阅读:238  来源: 互联网

标签:-- Desktop module 音视频 nginx location cd rtmp


本次搭建流媒体服务器是通过ubuntu18+nginx来完成

ubuntu地址 链接:https://pan.baidu.com/s/1OwvYRh40QUeKPqNrTOlClA 提取码:oge0
VMware虚拟机地址 链接:https://pan.baidu.com/s/1Mi-aPpgApVJaPOFjw2qFTw 提取码:ktwy

1、创建根目录


cd ~
mkdir rtmp
cd rtmp

2、首先需要下载


wget http://nginx.org/download/nginx-1.15.3.tar.gz
wget https://codeload.github.com/arut/nginx-rtmp-module/tar.gz/v1.2.1

3、安装git工具


yum install git

4、解压


tar xvf v1.2.1
tar xvf nginx-1.15.3.tar.gz

5、进入nginx目录


cd nginx-1.15.3

6、生成nginx 安装文件


#--add-module 指向rtmp模块目录
./configure --prefix=./bin --add-module=../nginx-rtmp-module-1.2.1
make instal

在这个过程中可能因为环境不同而出现不同错误,比如缺少pcre、openssl等,这时候就需要安装这些
库。 ubuntu下安装nginx时依赖库zlib,pcre,openssl安装方法

我遇见了这个报错 Ubuntu Server 上在安装Nginx时执行./confgiure后提示:C compiler cc is not found

7、cd到 cd bin/conf目录下


8、配置


vim conf/nginx.conf

user root;
worker_processes  1;

error_log /home/ruby/Desktop/rtmp/nginx-1.15.3/bin/logs/error.log debug;

events {
    worker_connections  1024;
}

rtmp {
	server {
		listen 1935;#之后推流拉流的端
		application live {
			live on;
			play /home/ruby/Desktop/rtmp/video;
		}
	}
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    sendfile        on;

    keepalive_timeout  65;

    #gzip  on;

    server {
        listen       8080;
        server_name  localhost;

	location /stat.xsl {
		root /home/ruby/Desktop/rtmp/nginx-rtmp-module-1.2.1;
	}

	location /stat {
		rtmp_stat all;
		rtmp_stat_stylesheet stat.xsl;
	}


	location /control{
		rtmp_control all;
	}

	location /rtmp-publisher
	{	
		root /home/ruby/Desktop/rtmp/nginx-rtmp-module-1.2.1/test;
	}

     location / {
      	root /home/ruby/Desktop/rtmp/nginx-rtmp-module-1.2.1/test/www;
	}

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}

9、回退到nginx-1.15.3目录下


10、运行nginx


./bin/sbin/nginx -c conf/nginx.conf

检查nginx是否重启成功

cd bin/sbin
nginx -t

停止nginx进程

ps -ef|grep nginx

配置完成后重启nginx

nginx -s reload

11、查看效果


Terminal如果没有什么报错,就可以查看效果了,有报错还需要根据提示修改,大致效果如下。
在这里插入图片描述

12、点播


在ubuntu中存放视频。
在这里插入图片描述
vlc中输入RTMP地址就可以查看点播效果。
在这里插入图片描述
window中文件拷贝到ubuntu中,我电脑上会卡死,我这样解决的 将Windows中的文件拖拉到虚拟机(Ubuntu)中

13、参考


1 . Ubuntu Server 上在安装Nginx时执行./confgiure后提示:C compiler cc is not found

2 .ubuntu18流媒体服务器搭建

3 .将Windows中的文件拖拉到虚拟机(Ubuntu)中

标签:--,Desktop,module,音视频,nginx,location,cd,rtmp
来源: https://blog.csdn.net/qq_18242391/article/details/112731287

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有