nginxRTMP协议服务器

by ahuner

通过以下的配置,可以使nginx接收RTMP流,并在web上播放实时视频。

1.openssl安装

nginx需要http_ssl_module模块,需要openssl库。

下载opensll:http://www.openssl.org/

最新稳定版本:openssl-1.0.1e

修改三个文件的代码,openssl-1.0.1e\test中的md2test.c、rc5test.c、jpaketest.c

将dummytest.c修改为#include "dummytest.c"。

编译:

chmod +x config

编译静态库

./config --prefix=/usr/local --openssldir=/usr/local/opensll

make && make install

编译动态库

./config shared --prefix=/usr/local --openssldir=/usr/local/opensll

make clean

make && make install

2.nginx的rtmp模块

下载nginx-rtmp-module

https://github.com/arut/nginx-rtmp-module

3.nginx安装

./configure \

--prefix=/usr/local/nginx \

--sbin-path=/usr/local/nginx/nginx \

--conf-path=/usr/local/nginx/nginx.conf \

--pid-path=/usr/local/nginx/nginx.pid \

--error-log-path=/usr/local/nginx/logs/error.log \

--with-pcre=../pcre-8.31 \

--with-zlib=../zlib-1.2.7 \

--with-http_dav_module \

--with-http_flv_module \

--with-http_stub_status_module \

--without-http_scgi_module \

--without-http_uwsgi_module \

--without-http_gzip_module \

--without-http_ssi_module \

--without-http_proxy_module \

--without-http_memcached_module \

--without-http_empty_gif_module \

--without-mail_pop3_module \

--without-mail_imap_module \

--without-mail_smtp_module \

--with-http_ssl_module \

--with-openssl=/project/openssl-1.0.1e \

--add-module=/project/nginx-rtmp-module-master

注意:/project/openssl-1.0.1e为openssl的源代码目录,编译nginx的时候会自动编译连接openssl.

make && make install

4.nginx.conf

配置文件:

#user  nobody;
worker_processes  1;

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

#pid        logs/nginx.pid;

events {
    worker_connections  1024;
}

rtmp {
    server {
        listen 1935;

chunk_size 4096;

application myapp {
            live on;
        }
    }
}

http {
    server {
        listen      80;

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

location /stat.xsl {
            root /project/nginx-rtmp-module-master/;
        }

location / {
            root /project/nginx-rtmp-module-master/test/rtmp-publisher;
        }
    }
}

5.推流

"rtmp://192.168.1.102/myapp"表示url, "test1"表示stream

推流方式1:ffmpeg -re -i ~/2012.flv -f flv rtmp://192.168.1.102/myapp/test1

推流方式2:Adobe Flash Media Live Encoder设置上述参数

6.直播播放

用nginx-rtmp-module自带的一个例子修改,在test/rtmp-publisher目录下player.html

<!DOCTYPE html>

<html>

<head>

<title>RTMP Player</title>

<script type="text/javascript" src="swfobject.js"></script>

<script type="text/javascript">

var flashVars = {

streamer: 'rtmp://192.168.1.102/myapp',

file:'test1'

};

swfobject.embedSWF("RtmpPlayer.swf", "rtmp-publisher", "500", "400", "9.0.0",

null, flashVars);

</script>

</head>

<body>

<div id="rtmp-publisher">

<p>Flash not installed</p>

</div>

</body>

</html>

访问http://192.168.1.102/player.html

参考

Nginx RTMP 功能研究:

http://blog.csdn.net/cccallen/article/details/8440191

nginx的RTMP协议服务器的更多相关文章

  1. nginx搭建rtmp协议流媒体服务器总结

    最近在 ubuntu12.04+wdlinux(centos)上搭建了一个rtmp服务器,感觉还挺麻烦的,所以记录下. 大部分都是参考网络上的资料. 前提: 在linux下某个目录中新建一个nginx ...

  2. 基于nginx的rtmp直播服务器(nginx-rtmp-module实现)

    首先,在搭建服务之前先了解下目前主流的几个直播协议: 1.RTMP: 实时消息传输协议,Real Time Messaging Protocol,是 Adobe Systems 公司为 Flash 播 ...

  3. 基于nginx的rtmp的服务器(nginx-rtmp-module)

    一,首先下载安装nginx需要依赖的库文件: 1.1,选定源码目录 选定目录 /usr/local/RTMP cd /usr/local/RTMP 1.2,安装PCRE库 cd /usr/local/ ...

  4. Nginx 搭建rtmp直播服务器

    1.到nginx源码目录新建个rtmp目录 ,进入  git clone https://github.com/arut/nginx-rtmp-module.git   2.重编译nginx 代码如下 ...

  5. Nginx均衡TCP协议服务器案例

    Nginx在企业运维中通常用来均衡HTTP协议,例如我们熟知的80.8080.8081等服务.因为大部分的服务都是http请求访问协议,那有时候需要用到TCP协议,如果来实现均衡呢? 默认nginx不 ...

  6. ubuntu 上采用nginx做rtmp 直播 服务器

    首先安装必要的依赖库   sudo apt-get install autoconf automake sudo apt-get install libpcre3 libpcre3-dev   安装 ...

  7. 基于Nginx的Rtmp流媒体服务器环境搭建

    一.编译安装 wget http://nginx.org/download/nginx-1.4.2.tar.gz wget https://github.com/arut/nginx-rtmp-mod ...

  8. nginx搭建http和rtmp协议的流媒体服务器

    nginx搭建http和rtmp协议的流媒体服务器 时间:2013-09-23 23:52来源:佚名 作者:本站 举报 点击:232次 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtm ...

  9. 利用Nginx搭建http和rtmp协议的流媒体服务器[转]

    利用nginx搭建http和rtmp协议的流媒体服务器 实验目的:让Nginx支持flv和mp4格式文件,同时支持Rtmp协议:同时打开rtmp的hls功能资料:HTTPLive Streaming( ...

随机推荐

  1. nefu 179 珠子(最长递增子序列问题)

    Description 小林有一串珠子,是由很多个大小不同的珠子串联在一起组成的圆环型的,且其中每个珠子的大小可以用int型的整数来表示.小林有一个爱好就是数珠子,他想数那些位置相邻而且大小只相差1的 ...

  2. 删除 mysql 日志文件后 ,启动出错

    把 mysql-bin.index 里面的索引全部删除

  3. QML Flipable、Flickable和状态与动画 上篇

    本文介绍的是QML Flipable.Flickable和状态与动画,我们以前接触过QML组件,和一些QML相关的内容,那么本文介绍的内容就很明了了.先来看内容. AD:51CTO 网+ 第十二期沙龙 ...

  4. C#抓取页面时候,获取页面跳转后的地址

    static string fanhuiurl(string cahxunurl) { string url = ""; HttpWebRequest req = (HttpWeb ...

  5. 不同版本(2.3,2.4,2.5) web.xml 的web-app头信息

    原址:点击打开链接 Servlet 2.3 <?xml version="1.0" encoding="UTF-8"?><!DOCTYPE w ...

  6. linux文件系统命令

    1. df df -h 2.查看文件系统的类型 df -T tmpfs文件系统所知道的就是它正在使用某种形式的虚拟内存.tmpfs是一种基于内存的文件系统.而tmpfs是一个文件系统,并不是块设备,只 ...

  7. Timewarp 一种生成当中帧技术,异步时间扭曲(Asynchronous Timewarp)

    翻译: https://www.oculus.com/blog/asynchronous-timewarp/    异步时间扭曲(Asynchronous Timewarp 时间扭曲,即调整时长) 关 ...

  8. POJ 1067 取石子游戏 威佐夫博弈

    威佐夫博弈(Wythoff Game):有两堆各若干个物品,两个人轮流从某一堆或同时从两堆中取同样多的物品,规定每次至少取一个,多者不限,最后取光者得胜. 我们用(ak,bk)(ak ≤ bk ,k= ...

  9. 百度地图API地点搜索-获取经纬度

    分享一下地图上的地点搜索和鼠标点击获取地点经纬度,这些都是地图比较基本和实用的代码,其中还包括了根据用户IP进行地图的显示.改变地图上的鼠标样式.启用滚轮缩放等,算是半入门吧,其他的一些可以自己参考百 ...

  10. Linux试题及答案

    一. 单选题: 1.添加一条静态路由,使到网络196.199.3通过eth2接口出去,用: A. route add -net 196.199.3.0 B. route add -net 196.19 ...