nginx《二》:nginx服务器直播RTMP流简单实例

欢迎转载请注明出处:海漩涡

http://blog.csdn.net/tanhuifang520


                                          nginx服务器直播RTMP流简单实例


看此文章前可看前一篇搭建nginx


一、nginx直播配置

(1)修改配置文件:/usr/local/nginx/conf/nginx.conf,添加live配置

worker_processes  1;

events {
    worker_connections  1024;
}

rtmp {
    server { 
        listen 1935;
    chunk_size 4096;

    application vod {
        play /opt/video/vod;
    }

    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 /stat {     #第二处添加的location字段。
            rtmp_stat all;
        rtmp_stat_stylesheet stat.xsl;
    }

    location /stat.xsl { #第二处添加的location字段。
        root /usr/local/nginx/nginx-rtmp-module/;
    }

        location / {
            root   html;
            index  index.html index.htm;
        }

        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }
    }
}


(2)重启nginx服务

sudo /usr/local/nginx/sbin/nginx -s reload




二、使用ffmpeg推RTMP流到nginx服务器

(1)下载ffmpeg源码:FFmpeg-release-2.5.zip

https://github.com/FFmpeg/FFmpeg/tree/release/2.5

(2)编译

    cd FFmpeg-release-2.5

    ./configure

    make


(3)拷贝一个视频文件:steve_jobs.flv 到FFmpeg-release-2.5目录下


(4)ffmpeg推RTMP流

    cd FFmpeg-release-2.5

    ./ffmpeg -re -i steve_jobs.flv -c copy -f flv rtmp://10.10.12.228/live/test

    上IP为运行nginx的主机IP。


三、使用VLC播放

(1)媒体->打开网络串流,然后输入URL:   rtmp://10.10.12.228/live/test

其中IP为运行nginx主机的IP



(2)点击上图右下角的播放就能看到视频了



参考:

http://blog.csdn.net/kingroc/article/details/50839994

http://blog.csdn.net/leixiaohua1020/article/details/12029543


欢迎转载请注明出处:海漩涡

http://blog.csdn.net/tanhuifang520


猜你喜欢

转载自blog.csdn.net/tanhuifang520/article/details/79614673
今日推荐