Skip to content

Instantly share code, notes, and snippets.

@tunglam14
Created November 15, 2017 18:43
Show Gist options
  • Save tunglam14/a11f53a4b771ba6452293dacd9408a5c to your computer and use it in GitHub Desktop.
Save tunglam14/a11f53a4b771ba6452293dacd9408a5c to your computer and use it in GitHub Desktop.
  1. Dựng nginx với rtmp support https://github.com/arut/nginx-rtmp-module
  2. Cấu hình rtmp server
rtmp {
        server {
                listen 1935;
                application live {
                        live on;
                        hls on;
                        hls_path /tmp/hls;
                }
        }
}
  1. Cấu hình nginx serve m3u8 file:
http {
    ...
    server {
        listen       80;
        server_name  _;

        location /hls {
            types {
                application/vnd.apple.mpegurl m3u8;
                video/mp2t ts;
            }
            root /tmp;
            add_header Cache-Control no-cache;
        }

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

  1. Transcode rtsp sang rtmp dùng ffmpeg:
ffmpeg -i "[your rtsp link]" -f flv -c copy rtmp://ip_rmtp_server:port/live/streamname
  1. m3u8 file được serve ở http://ip_rmtp_server/hls/streamname.m38u
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment