ubuntu nginx+rtmp配置及简单测试

1.安装nginx和nginx-rtmp-module

wget http://nginx.org/download/nginx-1.4.0.tar.gz
git clone https://github.com/arut/nginx-rtmp-module.git

./configure --add-module=../nginx-rtmp-module-master
make && sudo make install

启动:

sudo /usr/local/nginx/sbin/nginx

 2.修改配置文件

#user  nobody;
worker_processes  1;

#error_log  logs/error.log;
#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 4000;

        application live {
            live on;
            hls on;
            hls_path /home/ubuntu/test;
            hls_fragment 5s;
        }
    }
}

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;
    #fcgi配置
    server {
        listen 80;
        listen [::]:80;

        server_name 127.0.0.1;

        location / {
            root /var/www/html;
            index index.html index.htm index.nginx-debian.html;
        }

        location ^~ /cgi-bin/entry.cgi/ {
            include fastcgi.conf;
            fastcgi_pass 127.0.0.1:9000;
        }

    }
}

3.重启nginx

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

4.ubuntu使用ffmpeg进行推流

ffmpeg -re -i welcom_to_beijing.mp4 -vcodec libx264 -acodec aac  -f flv rtmp://192.168.1.10:1935/live/test

5.window端vlc软件拉流,输入地址:rtmp://192.168.1.10:1935/live/test 即可看到ubuntu推出的视频