nginx安装配置视频频服务器-windows

news2024/9/20 20:52:37

编译安装nginx

1、安装perl

安装地址: https://strawberryperl.com,选择msi安装程序即可

2、安装sed for windows

下载地址:https://sourceforge.net/projects/gnuwin32/files/sed/,执行安装程序结束后,将安装包bin目录配置到环境变量下

3、安装visual studio 2022 community版

4、从https://github.com/nginx/nginx下载1.26.1版源码,在源码中新建目录objs\lib

下载nginx-http-flv-module:https://github.com/winshining/nginx-http-flv-module (1.2.10版)

下载pcre: https://github.com/PCRE2Project/pcre2/tags (10.2.39版)

下载zlib: https://github.com/madler/zlib (1.3.1版)

下载openssl:https://www.openssl.org/source/index.html (3.0.13版)

将nginx-http-flv-module、openssl、pcre、zlib拷贝到该目录中并解压

5、查看nginx编译参数

下载nginx-1.26.1已经编译完成的版本,执行 nginx.exe -V,得到如下结果:

configure arguments: --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-pcre=objs.msvc8/lib/pcre2-10.39 --with-zlib=objs.msvc8/lib/zlib-1.3.1 --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_flv_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-stream_realip_module --with-stream_ssl_preread_module --with-openssl=objs.msvc8/lib/openssl-3.0.13 --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module

修改部分参数:

--with-pcre=objs/lib/pcre2-10.39 --with-zlib=objs/lib/zlib-1.3.1 --with-openssl=objs/lib/openssl-3.0.13 --add-module=objs/lib/nginx-http-flv-module-1.2.10

7、configure

运行MSYS2或者MINGW64,进入nginx源码nginx-release-1.26.1中,执行命令:

auto/configure --with-cc=cl --builddir=objs.msvc8 --with-debug --prefix= --conf-path=conf/nginx.conf --pid-path=logs/nginx.pid --http-log-path=logs/access.log --error-log-path=logs/error.log --sbin-path=nginx.exe --http-client-body-temp-path=temp/client_body_temp --http-proxy-temp-path=temp/proxy_temp --http-fastcgi-temp-path=temp/fastcgi_temp --http-scgi-temp-path=temp/scgi_temp --http-uwsgi-temp-path=temp/uwsgi_temp --with-cc-opt=-DFD_SETSIZE=1024 --with-http_v2_module --with-http_realip_module --with-http_addition_module --with-http_sub_module --with-http_dav_module --with-http_stub_status_module --with-http_mp4_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_random_index_module --with-http_secure_link_module --with-http_slice_module --with-mail --with-stream --with-stream_realip_module --with-stream_ssl_preread_module --with-openssl-opt='no-asm no-tests -D_WIN32_WINNT=0x0501' --with-http_ssl_module --with-mail_ssl_module --with-stream_ssl_module --with-pcre=objs/lib/pcre2-10.39 --with-zlib=objs/lib/zlib-1.3.1 --with-openssl=objs/lib/openssl-3.0.13 --add-module=objs/lib/nginx-http-flv-module-1.2.10

修改objs.msvc8/Makefile,修改第三行:

CFLAGS =  -O2  -W4 -WX -nologo -MT -Zi -Fdobjs.msvc8/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H

去掉-WX,加上-MP

CFLAGS =  -O2  -W4 -MP -nologo -MT -Zi -Fdobjs.msvc8/nginx.pdb -DFD_SETSIZE=1024 -DNO_SYS_TYPES_H

8、编译
打开Developer Command Prompt for VS 2022,进入nginx源码目录,输入命令:nmake,回车

编译时间需要10-30分钟,结束后,在objs.msvc8下的nginx.exe复制到nginx源码目录下。

新建目录logs、temp、html。

9、安装ffmpeg

下载安装,并将ffmpeg的bin目录设置为环境变量

配置nginx

修改conf/nginx.conf

worker_processes 1;
 
events {
    worker_connections 1024;
}
 
http {
    include mime.types;
    default_type application/octet-stream;
 
    sendfile on;
    keepalive_timeout 65;
    
    server {
        listen 8553;
        server_name localhost;
        
        location / {
            root html;
            index index.html index.htm;
        }
 
        location /live {
            flv_live on;
            chunked_transfer_encoding on;
            add_header 'Access-Control-Allow-Origin' '*';
            add_header 'Access-Control-Allow-Credentials' 'true';
            add_header 'Access-Control-Allow-Methods' '*';
        }
 
        location /hls {
            add_header 'Access-Control-Allow-Origin' '*';
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            alias /test;
            expires -1;
        }
 
        location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
 
        location /stat.xsl {
            root /usr/local/nginx/nginx-http-flv-module;
        }
    }
}
 
rtmp {
    server {
        listen 1938; #nginx监听的rtmp推流/拉流端口
        application myapp {
            live on; #当推流时,rtmp路径中的app(rtmp中的一个概念)匹配myapp时,开始直播
            meta off;
            gop_cache on;
            allow play all;
            record off;
            hls on;
            hls_path /test;
            hls_fragment 1s;
        }
    }
}

ffmpeg推流(海康摄像头)

ffmpeg -i rtsp://用户名:密码@ip:554/H.264/ch1/main/av_stream -c:v libx264 -an -f
flv rtmp://127.0.0.1:1938/myapp/main

测试

flv.html

<html>
<head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
    <title>flv.js demo</title>
    <style>
        .mainContainer {
            display: block;
            width: 1024px;
            margin-left: auto;
            margin-right: auto;
        }
 
        .urlInput {
            display: block;
            width: 100%;
            margin-left: auto;
            margin-right: auto;
            margin-top: 8px;
            margin-bottom: 8px;
        }
 
        .centeredVideo {
            display: block;
            width: 100%;
            height: 576px;
            margin-left: auto;
            margin-right: auto;
            margin-bottom: auto;
        }
 
        .controls {
            display: block;
            width: 100%;
            text-align: center;
            margin-left: auto;
            margin-right: auto;
        }
    </style>
</head>
 
<body>
 
<p class="mainContainer">
    <video name="videoElement" id="videoElement" class="centeredVideo" controls muted autoplay width="1024"
           height="576">
        Your browser is too old which doesn't support HTML5 video.
    </video>
</p>
 
<script src="flv.min.js"></script>
 
<script>
 
    function start() {
        if (flvjs.isSupported()) {
            var videoElement = document.getElementById('videoElement');
            var flvPlayer = flvjs.createPlayer({
                type: 'flv',
				url: 'http://ip:8553/live?port=1938&app=myapp&stream=main'
            });
            flvPlayer.attachMediaElement(videoElement);
            flvPlayer.load();
            flvPlayer.play();
        }
    }
 
    document.addEventListener('DOMContentLoaded', function () {
        start();
    });
</script>
</body>
 
</html>

flv.min.js 下载地址: http://flv.jnyzh.cn/flv.min.js

效果如下:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1916552.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

如何在 C 语言中进行选择排序?

&#x1f345;关注博主&#x1f397;️ 带你畅游技术世界&#xff0c;不错过每一次成长机会&#xff01; &#x1f4d9;C 语言百万年薪修炼课程 通俗易懂&#xff0c;深入浅出&#xff0c;匠心打磨&#xff0c;死磕细节&#xff0c;6年迭代&#xff0c;看过的人都说好。 文章目…

阿里云操作系统智能助手OS Copilot实验测评报告

简介&#xff1a;作为一名学生&#xff0c;阿里云操作系统智能助手OS Copilot对学生的帮助主要体现在提高学习效率、简化操作流程和优化系统管理等方面。通过其丰富的功能&#xff0c;从系统信息的快速获取到复杂的系统运维管理&#xff0c;OS Copilot都能为学生提供极大的便利…

计算机毕业设计Python深度学习游戏推荐系统 Django PySpark游戏可视化 游戏数据分析 游戏爬虫 Scrapy 机器学习 人工智能 大数据毕设

本论文的主要研究内容如下&#xff1a; 了解基于Spark的TapTap游戏数据分析系统的基本架构&#xff0c;掌握系统的开发方法&#xff0c;包括系统开发基本流程、开发环境的搭建、测试与运行等。 主要功能如下&#xff1a; &#xff08;1&#xff09;用户管理模块&#xff1a…

vue3 + i18n 中英文切换

第一步&#xff1a;安装vue-i18n npm install vue-i18n 第二步&#xff1a;配置语言包及js文件 目录如下&#xff1a; 英文语言包 en.js // lang/en.js - 英文语言包 export default {menu: { 库房管理: Warehouse Management,入库检测: Incoming Inspection, 设…

【计算机网络仿真】b站湖科大教书匠思科Packet Tracer——实验18 边界网关协议BGP

一、实验目的 1.验证边界网关协议BGP的作用&#xff1b; 2.学习在思科路由器上该协议的使用方法。 二、实验要求 1.使用Cisco Packet Tracer仿真平台&#xff1b; 2.观看B站湖科大教书匠仿真实验视频&#xff0c;完成对应实验。 三、实验内容 1.构建网络拓扑&#xff1b; …

算法力扣刷题记录 四十【226.翻转二叉树】

前言 继续二叉树其余操作&#xff1a; 记录 四十【226.翻转二叉树】 一、题目阅读 给你一棵二叉树的根节点 root &#xff0c;翻转这棵二叉树&#xff0c;并返回其根节点。 示例 1&#xff1a; 输入&#xff1a;root [4,2,7,1,3,6,9] 输出&#xff1a;[4,7,2,9,6,3,1]示例…

Elasticsearch:使用 Filebeat 从 Node.js Web 应用程序提取日志

本指南演示了如何从 Node.js Web 应用程序中提取日志并将其安全地传送到 Elasticsearch Service 部署中。你将设置 Filebeat 来监控具有标准 Elastic Common Schema (ECS) 格式字段的 JSON 结构日志文件&#xff0c;然后在向 Node.js 服务器发出请求时&#xff0c;你将在 Kiban…

云开发技术的壁纸小程序源码,无需服务期无需域名

1、本款小程序为云开发版本&#xff0c;不需要服务器域名 2、文件内有图文搭建教程&#xff0c;小白也不用担心不会搭建。 3、本程序反应速度极快&#xff0c;拥有用户投稿、积分系统帮助各位老板更多盈利。 4、独家动态壁纸在线下载&#xff0c;给用户更多的选择 5、最新版套图…

“论基于构件的软件开发方法及其应用”精选范文,软考高级论文,系统架构设计师论文

论文真题 基于构作的软件开发 (Component-Based Software Development&#xff0c;CBSD) 是一种基于分布对象技术、强调通过可复用构件设计与构造软件系统的软件复用途径。基于构件的软件系统中的构件可以是COTS &#xff08;Commercial-Off-the-Shelf&#xff09;构件&#x…

“金山-讯飞”杯2024年武汉理工大学程序设计竞赛 A. Mobiusp败走***(思维题-点双连通分量、连通性)

题目 思路来源 官方题解 题解 手玩发现&#xff0c;能换的话&#xff0c;当且仅当.和1在一个环里&#xff0c;而这就是点双连通分量 所以最优策略是先把.换到(x,y)的位置&#xff0c;然后判断.和1在不在一个环里 也就是&#xff1a; 1. 判断删掉1时&#xff0c;.和(x,y)联…

Open3D 点云配准精度评价指标-RMSE

目录 一、概述 1.1RMSE的计算方法 1.2RMSE的评价标准 二、代码实现 三、实现效果 3.1原始点云 3.2计算数据 一、概述 均方根误差(RMSE, Root Mean Squared Error)是衡量两个点云之间平均误差的一个常用指标。它通过计算匹配点对之间距离的平方和的平方根,来…

Golang | Leetcode Golang题解之第227题基本计算器II

题目&#xff1a; 题解&#xff1a; func calculate(s string) (ans int) {stack : []int{}preSign : num : 0for i, ch : range s {isDigit : 0 < ch && ch < 9if isDigit {num num*10 int(ch-0)}if !isDigit && ch ! || i len(s)-1 {switch preS…

C++ | Leetcode C++题解之第227题基本计算器II

题目&#xff1a; 题解&#xff1a; class Solution { public:int calculate(string s) {vector<int> stk;char preSign ;int num 0;int n s.length();for (int i 0; i < n; i) {if (isdigit(s[i])) {num num * 10 int(s[i] - 0);}if (!isdigit(s[i]) &&am…

Linux文件:EXT2文件系统工作原理 软硬链接

Linux文件&#xff1a;文件系统究竟是什么&#xff1f;如何管理文件&#xff1f; 前言一、磁盘结构、存储策略1.1 磁盘存储结构1.2 磁盘存储策略1.3 磁盘的逻辑存储结构 二、如何管理磁盘文件三、如何管理组3.1 每个组保存的数据种类3.2 如何管理数据1、节点表&#xff08;inod…

CSS技巧专栏:一日一例 3.纯CSS实现炫酷多彩按钮特效

大家好,今天是 CSS技巧专栏:一日一例 第三篇《纯CSS实现炫酷多彩按钮特效》 先看图: 开工前的准备工作 正如昨日所讲,为了案例的表现,也处于书写的习惯,在今天的案例开工前,先把昨天的准备工作重做一遍。 清除浏览器的默认样式定义页面基本颜色设定body的样式清除butt…

LNMP搭建Discuz和Wordpress

1、LNMP L:linux操作系统 N&#xff1a;nginx展示前端页面web服务 M&#xff1a;mysql数据库&#xff0c;保存用户和密码&#xff0c;以及论坛相关的内容 P&#xff1a;php动态请求转发的中间件 数据库的作用&#xff1a; 登录时验证用户名和密码 创建用户和密码 发布和…

Groovy vs Kotlin 在Gradle配置文件中的差异与选择

人不走空 &#x1f308;个人主页&#xff1a;人不走空 &#x1f496;系列专栏&#xff1a;算法专题 ⏰诗词歌赋&#xff1a;斯是陋室&#xff0c;惟吾德馨 目录 &#x1f308;个人主页&#xff1a;人不走空 &#x1f496;系列专栏&#xff1a;算法专题 ⏰诗词歌…

思维+dfs+二染色,CF 1060E - Sergey and Subway

一、题目 1、题目描述 2、输入输出 2.1输入 2.2输出 3、原题链接 1060E - Sergey and Subway 二、解题报告 1、思路分析 考虑修改后的图&#xff0c;任意两点间的距离有何变化&#xff1f; 除2向上取整 那么我们要求的就是Σ[d / 2] 直接求太慢了&#xff0c;考虑求每个…

GitHub 站点打不开

遇到的问题 您是否遇到过GitHub网站打不开的情况&#xff0c;正如下图所示&#xff1a; 解决方案 以下是一些常见的解决方案&#xff1a; 1. 检查网络连接 确保你的设备已连接到互联网。尝试访问其他网站&#xff0c;确保不是你的网络问题。 C:\Vinca>ping github.…

Html:点击图标/链接发起QQ临时会话

我们在做前端开发的时候&#xff0c;会遇到用户需要点击一个图标可以发起QQ临时会话&#xff0c;这样不用添加好友也能沟通的&#xff0c;那我们就来看看如何实现这个功能&#xff1a; <a href"http://wpa.qq.com/msgrd?v3&uin你的QQ号码&siteqq&menuyes…