使用nginx搭建媒体点播服务器

使用nginx搭建媒体点播服务器

最新由于兴趣,对ubuntu和安卓上的视频点播直播等应用比较感兴趣,所以在vmware的虚拟机里面搭建了一个视频点播网站,参考了fengzhanhai的文章Nginx搭建视频点播服务器(仿真专业流媒体软件)。

1,环境的准备

1)下载vmware,当然破解版本

2)安装ubuntu 64bit版本,老的电脑可能需要bios里面设置,设置方法百度去。

3)执行sudo apt-get update & sudo apt-get install yum

4)执行sudo apt-get install g++;编译安装pcre的时候需要

2,软件准备

openssl-1.0.1f.zip

JW_Player5.2  ##flash播放器控件

nginx-1.3.3.tar.gz  ##服务器主程序

yamdi-1.4.tar.gz  ##渐进式流支持模块(抓取视频资源关键帧实现播放时的随意拖动效果)

nginx-accesskey-2.0.3

zlib-1.2.3.tar.gz

nginx_mod_h264_streaming-2.2.7.tar.gz  ##MP4支持模块

zlib-1.2.3.tar.gz.1

openssl-1.0.1f.tar.gz

pcre-8.32.tar.gz

3, 编译

1)安装yamdi

A)、解压下载的文件tar –zxvf yamdi-1.8.tar.gz

B)、进入解压后的目录cd yamdi-1.8.

C)、编译并安装 make && make install

D)、使用该软件为视频添加关键帧信息实现拖动效果

具体使用方法如下yamdi -i input.mp4 -o out.mp4 (拖拽功能必须的一步呀)

2) 安装Nginx

A)下载最新版本的Nginx程序(为了安装教程,使用的并不是最新版本)

wget http://nginx.org/download/nginx-1.3.3.tar.gz

3) 访问http://h264.code-shop.com官网下载最新版本的MP4支持模块

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

下载pcre包

wget  http://autosetup1.googlecode.com/files/pcre-8.32.tar.gz

4) 下载zlib包

wget http://google-desktop-for-Linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz

5) 加压并编译pcre

tar pcre-8.32.tar.gz

Cd pcre-8.32

 ./configure –prefix=/usr/local/pcre

Make

Sudo make install

6) 编译nginnx

./configure  --add-module=../nginx_mod_h264_streaming-2.2.7 --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.3  --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-http_mp4_module  --with-cc-opt='-O3' --with-openssl=../openssl-1.0.1f

Make

继续编译该软体使用make命令,哈哈报错啦!(有error信息打印不见的是一件坏事哦)报错信息如下:

make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1

make: *** [build] Error 2

解决方法:

进入支持MP4格式播放的库/nginx/nginx_mod_h264_streaming-2.2.7/src修改ngx_http_h264_streaming_module.c该文件。修改内容如下所示:

将如下几行注释
/* TODO: Win32 */
if (r->zero_in_uri)
{
return NGX_DECLINED;
}后我们再次make clean && make一下nginx,呵呵这次终于成功了。

 

Sudo make install

 

注意,所有其他软件包都必须使用zip或者tar命令解开,而且注意configure的时候路径一致。

 

3)配置nginx服务器

sudo gedit /usr/local/nginx/conf/nginx.conf

修改为

 

#user  nobody;

#user  videoapp video;  ##管理用户

worker_processes  8;

 

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

pid        /usr/local/nginx/logs/nginx.pid;

 

events {

    use epoll;

    worker_connections  1024;

}

 

 

http {

    include       mime.types;

    default_type  application/octet-stream;

 

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

 

    access_log  logs/access.log  main;

 

    sendfile        on;

    tcp_nopush     on;

 

    #keepalive_timeout  0;

    keepalive_timeout  65;

 

    #gzip  on;

 

    server {

        listen       801;

        server_name  localhost;

 

        #charset koi8-r;

 

        limit_rate_after 5m;

 

        limit_rate  512k;

 

        charset utf-8;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   html;

            index  index.html index.htm;

        }

 

location ~ \.flv$ {

 

                         flv;

 

                        }

 

       location ~ \.mp4$ {

 

                         mp4;

 

                        }

 

       location ~(favicon.ico) {

 

                        log_not_found off;

 

                        expires 30d;

 

                        break;

 

                               }

 

        #error_page  404              /404.html;

 

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

 

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}

 

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}

 

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }

 

 

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

 

    # HTTPS server

    #

    #server {

    #    listen       443;

    #    server_name  localhost;

 

    #    ssl                  on;

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

 

    #    ssl_session_timeout  5m;

 

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers   on;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

}

4)启动服务器

Sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

在/usr/local/nginx/html目录下建立video目录,拷贝视频及falsh播放器到video目录下

5)播放

http://127.0.0.1:801/player.swf?type=http&file=xxy.mp4

使用nginx搭建媒体点播服务器

最新由于兴趣,对ubuntu和安卓上的视频点播直播等应用比较感兴趣,所以在vmware的虚拟机里面搭建了一个视频点播网站,参考了fengzhanhai的文章Nginx搭建视频点播服务器(仿真专业流媒体软件)。

1,环境的准备

1)下载vmware,当然破解版本

2)安装ubuntu 64bit版本,老的电脑可能需要bios里面设置,设置方法百度去。

3)执行sudo apt-get update & sudo apt-get install yum

4)执行sudo apt-get install g++;编译安装pcre的时候需要

2,软件准备

openssl-1.0.1f.zip

JW_Player5.2  ##flash播放器控件

nginx-1.3.3.tar.gz  ##服务器主程序

yamdi-1.4.tar.gz  ##渐进式流支持模块(抓取视频资源关键帧实现播放时的随意拖动效果)

nginx-accesskey-2.0.3

zlib-1.2.3.tar.gz

nginx_mod_h264_streaming-2.2.7.tar.gz  ##MP4支持模块

zlib-1.2.3.tar.gz.1

openssl-1.0.1f.tar.gz

pcre-8.32.tar.gz

3, 编译

1)安装yamdi

A)、解压下载的文件tar –zxvf yamdi-1.8.tar.gz

B)、进入解压后的目录cd yamdi-1.8.

C)、编译并安装 make && make install

D)、使用该软件为视频添加关键帧信息实现拖动效果

具体使用方法如下yamdi -i input.mp4 -o out.mp4 (拖拽功能必须的一步呀)

2) 安装Nginx

A)下载最新版本的Nginx程序(为了安装教程,使用的并不是最新版本)

wget http://nginx.org/download/nginx-1.3.3.tar.gz

3) 访问http://h264.code-shop.com官网下载最新版本的MP4支持模块

wget http://h264.code-shop.com/download/nginx_mod_h264_streaming-2.2.7.tar.gz

下载pcre包

wget  http://autosetup1.googlecode.com/files/pcre-8.32.tar.gz

4) 下载zlib包

wget http://google-desktop-for-linux-mirror.googlecode.com/files/zlib-1.2.3.tar.gz

5) 加压并编译pcre

tar pcre-8.32.tar.gz

Cd pcre-8.32

 ./configure –prefix=/usr/local/pcre

Make

Sudo make install

6) 编译nginnx

./configure  --add-module=../nginx_mod_h264_streaming-2.2.7 --with-pcre=../pcre-8.32 --with-zlib=../zlib-1.2.3  --prefix=/usr/local/nginx --with-http_flv_module --with-http_stub_status_module --with-http_mp4_module  --with-cc-opt='-O3' --with-openssl=../openssl-1.0.1f

Make

继续编译该软体使用make命令,哈哈报错啦!(有error信息打印不见的是一件坏事哦)报错信息如下:

make[1]: *** [objs/addon/src/ngx_http_h264_streaming_module.o] Error 1

make: *** [build] Error 2

解决方法:

进入支持MP4格式播放的库/nginx/nginx_mod_h264_streaming-2.2.7/src修改ngx_http_h264_streaming_module.c该文件。修改内容如下所示:

将如下几行注释
/* TODO: Win32 */
if (r->zero_in_uri)
{
return NGX_DECLINED;
}后我们再次make clean && make一下nginx,呵呵这次终于成功了。

 

Sudo make install

 

注意,所有其他软件包都必须使用zip或者tar命令解开,而且注意configure的时候路径一致。

 

3)配置nginx服务器

sudo gedit /usr/local/nginx/conf/nginx.conf

修改为

 

#user  nobody;

#user  videoapp video;  ##管理用户

worker_processes  8;

 

#error_log  logs/error.log;

#error_log  logs/error.log  notice;

#error_log  logs/error.log  info;

 

#pid        logs/nginx.pid;

pid        /usr/local/nginx/logs/nginx.pid;

 

events {

    use epoll;

    worker_connections  1024;

}

 

 

http {

    include       mime.types;

    default_type  application/octet-stream;

 

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '

                      '$status $body_bytes_sent "$http_referer" '

                      '"$http_user_agent" "$http_x_forwarded_for"';

 

    access_log  logs/access.log  main;

 

    sendfile        on;

    tcp_nopush     on;

 

    #keepalive_timeout  0;

    keepalive_timeout  65;

 

    #gzip  on;

 

    server {

        listen       801;

        server_name  localhost;

 

        #charset koi8-r;

 

        limit_rate_after 5m;

 

        limit_rate  512k;

 

        charset utf-8;

 

        #access_log  logs/host.access.log  main;

 

        location / {

            root   html;

            index  index.html index.htm;

        }

 

location ~ \.flv$ {

 

                         flv;

 

                        }

 

       location ~ \.mp4$ {

 

                         mp4;

 

                        }

 

       location ~(favicon.ico) {

 

                        log_not_found off;

 

                        expires 30d;

 

                        break;

 

                               }

 

        #error_page  404              /404.html;

 

        # redirect server error pages to the static page /50x.html

        #

        error_page   500 502 503 504  /50x.html;

        location = /50x.html {

            root   html;

        }

 

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80

        #

        #location ~ \.php$ {

        #    proxy_pass   http://127.0.0.1;

        #}

 

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

        #

        #location ~ \.php$ {

        #    root           html;

        #    fastcgi_pass   127.0.0.1:9000;

        #    fastcgi_index  index.php;

        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;

        #    include        fastcgi_params;

        #}

 

        # deny access to .htaccess files, if Apache's document root

        # concurs with nginx's one

        #

        #location ~ /\.ht {

        #    deny  all;

        #}

    }

 

 

    # another virtual host using mix of IP-, name-, and port-based configuration

    #

    #server {

    #    listen       8000;

    #    listen       somename:8080;

    #    server_name  somename  alias  another.alias;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

 

    # HTTPS server

    #

    #server {

    #    listen       443;

    #    server_name  localhost;

 

    #    ssl                  on;

    #    ssl_certificate      cert.pem;

    #    ssl_certificate_key  cert.key;

 

    #    ssl_session_timeout  5m;

 

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;

    #    ssl_ciphers  HIGH:!aNULL:!MD5;

    #    ssl_prefer_server_ciphers   on;

 

    #    location / {

    #        root   html;

    #        index  index.html index.htm;

    #    }

    #}

 

}

4)启动服务器

Sudo /usr/local/nginx/sbin/nginx -c /usr/local/nginx/conf/nginx.conf

在/usr/local/nginx/html目录下建立video目录,拷贝视频及falsh播放器到video目录下

5)播放

http://127.0.0.1:801/player.swf?type=http&file=xxy.mp4

时间: 2024-08-22 14:55:19

使用nginx搭建媒体点播服务器的相关文章

通过nginx搭建hls流媒体服务器

通过录像文件模拟直播源,通过rtmp协议推送到nginx服务器  nginx 配置文件 增加   [html] view plain copy     rtmp {         server {             listen 1935;            application hls {                  live on;                  hls on;                  hls_path /tmp/app;          

Nginx搭建FLV视频服务器方法

FLV有两种发布方式 一.普通的HTTP方式:这种方式通常需要预先下载到本地才能播放,有缓冲,但下载后就不会占用服务器资源. 二.流媒体方式:无需下载,可以实时播放任意拖拽进度,用户体验好但很耗服务器资源. 安装模块 在编译安装Nginx的时候把Flv Stream模块加上  代码如下 复制代码 ./configure --user=www --group=www --prefix=/usr/local/webserver/nginx --with-http_flv_module make &&a

Linux环境下nginx搭建简易图片服务器_nginx

主要使用Nginx和vsftpd. 安装方面可以直接从nginx官网上下载,或者... 复制代码 代码如下: yum install nginx  如果没有yum源则需要自行添加再进行install. 复制代码 代码如下: yum install wget wget http://www.atomicorp.com/installers/atomic  sh ./atomic  yum check update  如果是从官网上下载的则进行如下操作: 复制代码 代码如下: [root@admin

使用 nginx 和 rtmp 插件搭建视频直播和点播服务器

使用 nginx 和 rtmp 模块 ,可以很容易地搭建一个视频直播和点播服务器出来. 首先,看一下最经典的参考文献: How to set up your own private RTMP server using nginx 1. 安装 nginx 和 rtmp 模块 有关 nginx 的编译和安装比较简单,这里就不介绍了,看参考文献.这里提示以下几点: (1) 安装好 nginx 后,配置文件在这里: /usr/local/nginx/conf/nginx.conf (2) 启动 ngin

利用nginx搭建RTMP视频点播、直播、HLS服务器

开发环境 Ubuntu 14.04 server nginx-1.8.1 nginx-rtmp-module nginx的服务器的搭建 安装nginx的依赖库 sudo apt-get update sudo apt-get install libpcre3 libpcre3-dev sudo apt-get install openssl libssl-dev 配置并编译nginx 使用nginx的默认配置,添加nginx的rtmp模块.  ./configure --add-module=.

用nginx搭建http/rtmp/hls协议的MP4/FLV流媒体服务器

前前后后搭建了两三个星期,终于可以告一段落,nginx实在是有点强大.写一篇笔记来记录一下这个过程中的思路和解决方案. 一.搭建nginx平台: 基本是基于http://blog.csdn.net/xiaoliouc/article/details/8363984 一步步安装nginx搭建流媒体服务器 这篇博客来搭建. 我的ubuntu是14.04LTS.各种包的版本是: nginx-1.9.9 nginx_mod_h264_streaming-2.2.7.tar.gz openssl-0.9.

教你使用Nginx搭建web服务器

如果读者以前做过web开发的话,就应该知道如何去搭建一个web服务器来跑你的web站点,在windows下你可能会选择去用IIS,十分的快捷,在linux下,你可能首先会想到apache,"一哥"( W3Techs网站数据的排名)啦 今天小编要介绍后起之秀nginx来实现web服务器.小编在前面的博客中也详细的聊过apache的使用,如今又来说nginx的使用,读者可能以后搭建web服务器的话就不知道选用哪一种,O(∩_∩)O~,别急,小编这就来给读者分析一下Nginx和Apache区

用nginx搭建基于rtmp或者http的flv、mp4流媒体服务器

http://itindex.NET/detail/48702-nginx-rtmp-http   一.流媒体播放方式  1.  HTTP方式  这种方式要下载FLV视频文件到本地播放,一旦FLV视频文件下载完成,就不会消耗服务器的资源和带宽,但是拖动功能没有RTMP/RTMP流媒体方式强大,很多视频网站都是用HTTP方式实现的,如:YouTube,土豆,酷6等  2.  RTMP/RTMP流媒体方式  这种方式不用下载FLV视频文件到本地,可以实时的播放flv文件,可以任意拖拽播放进度条,但是

[终极精简版][图解]Nginx搭建flv mp4流媒体服务器

花了我接近3周,历经了重重问题,今日终于把流媒体服务器搞定,赶紧的写个博文以免忘记... 起初是跟着网上的一些教程来的,但是说的很不全面,一些东西也过时不用了(比如jwplayer老版本).我这次是用的最新版jwplayer6.8,在配置上有很多不同的地方,也很坑,值得注意一下!在配置方面,我精简了很多,没有了那么多繁琐的配置项需要修改. 注意:本人是在虚拟机centos6.2系统下搭建的流媒体服务器,在win7主机上做测试. 另,文章最后有下载地址,可下载搭建过程中所有用到的包和其他文件. 废