Friday, December 23, 2016

nginx streaming server


  1. download nginx from http://nginx.org
  2. unzip it, run nginx.exe, it is equal to run: nginx -c conf\nginx.conf we can change it default port from 80 to other. the trace and error log is in logs folder
  3. nginx command: 
  • nginx -s stop
  • nginx -s quit
  • nginx -s reload 
  • nginx -s reopen
  • nginx -V 
 we can use tasklist /fi "imagename eq nginx.exe" to check nginx task. or use taskkill /F /IM nginx.exe > nul  to close nginx

but, this version doesn't support streaming, so, we can change it to another version:

  1. http://nginx-win.ecsds.eu/  it contains nginx-rtmp-module . I get nginx 1.7.11.3 Gryphon
  2. modify the nginx-win.conf, add :
rtmp {

        server {

            listen 1935;

            chunk_size 4000;

            application live {

   live on;

   record off;

}
            application hls {
                live on;
                hls on;
                hls_path /tmp/hls;
            }
           application dash {
                live on;
                dash on;
                dash_path /tmp/dash;
            }
        }
    }
  1. start nginx: nginx.exe -c ./conf/nginx-win.conf
  2. broadcast one file: ffmpeg -re -i "C:\myprogram\testfile\test_1M.mp4" -c copy -f flv rtmp://localhost/live/stream
  3. play it from rtmp server: ffplay rtmp://localhost/live/stream

No comments:

Post a Comment