windows下Nginx-http-flv-module

1 nginx

window 需要编译 ,可以直接用这个编译好的 https://download.csdn.net/download/weixin_48985425/14159450?spm=1001.2014.3001.5503
rtmp application myapp

2 推流

rtmp://127.0.0.1:1985/myapp/mystream

3 页面播放 url

Z http://127.0.0.1:8080/live?port=1985&app=myapp&stream=mystream

在这里插入图片描述

nginx 配置

worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;
#error_log  logs/error.log  debug;

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}



# HTTP服务
http {
    include       mime.types;
    default_type  application/octet-stream;

    #access_log  logs/access.log  main;

    server {
        listen       8080; # 监听端口
 
		location /stat.xsl {
            root html;
        }
		location /stat {
            rtmp_stat all;
            rtmp_stat_stylesheet stat.xsl;
        }
		location / {
            root html;
        }
		###############流媒体
        location /live {
            flv_live on ; # 打开HTTP播放FLV直播流功能
            chunked_transfer_encoding on ; # 支持'Transfer-Encoding:  chunked'方式回复
            add_header 'Access-Control-Allow-Origin' '*'; # 添加额外的HTTP头
            add_header 'Access-Control-Allow-Credentials' 'true'; # 添加额外的HTTP头
			expires -1;
        }
    }
}
rtmp_auto_push on;
rtmp_auto_push_reconnect 1s;
rtmp_socket_dir logs;
# 添加RTMP服务
rtmp {
    out_queue           4096;
    out_cork            8;
    max_streams         128;
    timeout             15s;
    drop_idle_publisher 15s;

    log_interval 5s; #log模块在access.log中记录日志的间隔时间,对调试非常有用
    log_size     1m; #log模块用来记录日志的缓冲区大小

    server {
        listen 1985; # 监听端口、
        application myapp {
            live on ;
			gop_cache on ; #打开GOP缓存,减少首屏等待时间
			
			### 保存视频/start
			record video;                         #记录直播视频
			#record_path html/rec/;                 #视频保存路径
			#record_path  F:/ps/nginx-rtmp/html ;                 #视频保存路径
			#record_suffix -%d-%b-%y-%T.flv;       #视频保存名:日期+.flv# windows下测试时间作为文件名是吧
			#record_suffix -%d-%b-%y-%T.flv;      #视频保存名:日期+.flv
			### 保存视频/end
        }
    }
}

ffmpeg 下载地址

ffmpeg -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://127.0.0.1:1985/myapp/mystream
  • 1

网页

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></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: left;
		        margin-left: auto;
		        margin-right: auto;
		        margin-top: 8px;
		        margin-bottom: 10px;
		    }
		
		    .logcatBox {
		        border-color: #CCCCCC;
		        font-size: 11px;
		        font-family: Menlo, Consolas, monospace;
		        display: block;
		        width: 100%;
		        text-align: left;
		        margin-left: auto;
		        margin-right: auto;
		    }
		</style>
	</head>
	<script src="https://cdn.bootcss.com/flv.js/1.5.0/flv.js"></script>
	<script src="https://cdn.bootcdn.net/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
	<body>
		<div><input type="text" id='urlId' value="" /> <button type="button" id="butPlay">播放</button></div>
		<div class="mainContainer">
			<video name="videoElement" class="centeredVideo" id="videoElement" controls width="1024" height="576" autoplay='true'>
				Your browser is too old which doesn't support HTML5 video.
			</video>

		</div>
	</body>

	<script>
		console.log('start')
		// alert(flvjs.isSupported())
		if (flvjs.isSupported()) {
			play();

		}
		$("#butPlay").click(function(event){
			play();
		})
		function play(){
			var us = $("#urlId").val();
			console.info(new Date(), us)
			if (!us) {
				us = 'mystream'
			}
			var videoElement = document.getElementById('videoElement');
			var flvPlayer = flvjs.createPlayer({
				type: 'flv',
				enableWorker: true, //浏览器端开启flv.js的worker,多进程运行flv.js
				isLive: true, //直播模式
				hasAudio: false, //关闭音频             
				hasVideo: true,
				stashInitialSize: 128,
				enableStashBuffer: true, //播放flv时,设置是否启用播放缓存,只在直播起作用。
				url: ' http://127.0.0.1:8080/live?port=1985&app=myapp&stream=mystream'
			});
			
			flvPlayer.attachMediaElement(videoElement);
			flvPlayer.load();
			flvPlayer.play();
		}
	</script>
</html>

录制屏幕推送 HLS

--录制屏幕 推送 flv
ffmpeg -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f flv rtmp://127.0.0.1:1985/myapp/ck
--录制屏幕 推送 hls
ffmpeg -f gdigrab -i desktop -vcodec libx264 -preset:v ultrafast -tune:v zerolatency -f hls -hls_time 5.0 -h
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
要在Windows上部署nginx-http-flv-module,您需要按照以下步骤进行操作: 1. 首先,确保您的Windows系统已经安装了相应的编译环境,如CMake、MinGW等。您可以通过官方网站下载并安装这些软件。 2. 下载最新的nginx源代码,并解压到一个您方便操作的路径。 3. 下载nginx-http-flv-module源代码,解压到和nginx源代码相同的目录下。 4. 打开一个命令行终端,进入到nginx源代码的目录下。 5. 运行以下命令进行配置和编译:./configure --with-http_flv_module --with-http_ssl_module --with-cc=cl --builddir=objs --prefix=YOUR_INSTALL_PATH 其中,--with-http_flv_module用于指定启用http-flv模块,--with-http_ssl_module用于启用SSL模块,--with-cc=cl用于指定编译器为Microsoft Visual C++,--prefix=YOUR_INSTALL_PATH用于指定安装路径。 6. 运行make命令,进行编译。 7. 编译完成后,运行make install进行安装。安装完成后,您可以在YOUR_INSTALL_PATH目录下找到已安装的nginx。 8. 进入到已安装的nginx目录,找到conf/nginx.conf文件,并用文本编辑器打开。 9. 在http中添加如下配置: ``` flv { server { listen 8080; flv_live on; } } ``` 这样设置将启用flv模块,并在8080端口上监听请求。 10. 保存并关闭nginx.conf文件。 11. 运行nginx.exe启动nginx服务。 您现在已经成功部署了nginx-http-flv-module。您可以在浏览器中通过http://localhost:8080访问您的http-flv流。记得根据您的实际需求来进行配置和调整。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值