[nginx-rtmp]ffmpeg+video-js的推流和拉流

晚上十點過了,匆匆做下筆記趕緊碎覺

一nginx-rtmp配置

安裝好nginx-rtmp 修改配置如下
rtmp默認監聽1035端口,同時監聽80端口

worker_processes  1;

error_log  logs/error.log info;

events {
    worker_connections  1024;
}

rtmp_auto_push on;
rtmp {
    server {
        listen 1935;
		chunk_size 4096;
        application live {#直播模式
            live on;
        }
    }
}

http {
	include mime.types;
	default_type application/octet-stream;
	sendfile on;
	keepalive_timeout 65;	
	server {
		listen    80;
		server_name localhost;
        location / {
			root html;
            index live.html live.htm;
        }
	}
}

二 ffmpeg 推流和拉流

推流

在ffmpeg目錄下推送 big.mp4到 本機rtmp地址
ffmpeg.exe -re -i big.mp4 -vcodec h264 -f flv rtmp://127.0.0.1/live/vedio

拉流

拉取本機rtmp地址的流
ffplay.exe -i rtmp://127.0.0.1/live/vedio

三 頁面拉流

80端口訪問的live.html如下
調用videojs來拉流,不支持拉取127.0.0.1本地流
有的瀏覽器屏蔽了flash需要手動打開flash輸入

<a href=“https://get.adobe.com/cn/flashplayer/”; class=“flashLoadMsg”
target="_blank">啓動FLASH播放器

<html>
<head>
	<title>Live</title>
	<meta charset="utf-8">
	 <link href="http://vjs.zencdn.net/5.5.3/video-js.css" rel="stylesheet">
	<script src="http://vjs.zencdn.net/ie8/1.1.1/videojs-ie8.min.js"></script>
	<script src="http://vjs.zencdn.net/5.5.3/video.js"></script>
</head>
<body >
<h2 >推流測試</h2>
	<video id="my-video" class="video-js" controls preload="auto" width=" 640" height="360" data-setup="{}">
		<source src="rtmp://192.168.0.105/live/vedio" type="rtmp/flv">
	</video>
	<a href="https://get.adobe.com/cn/flashplayer/"; class="flashLoadMsg" target="_blank">啓動FLASH播放器</a>
</body>
</html>

ffmpeg 推流,打開網頁

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章