title: Nginx RTMP Module receive x.264 , output HLS live stream
body: <p><strong>Goal</strong>: Stream from PC using <a href="https://obsproject.com/" rel="noreferrer">OBS</a> , receive stream with Nginx RTMP Module and output to viewers so that they can view the <strong>live stream</strong> both on PC and mobile. For that to happen, Nginx must output live stream with HLS. </p>
  
  <p>My partner has set up the following Nginx file, but nothing occurs (it was done following this answer from stackoverflow --> <a href="https://stackoverflow.com/questions/19658216/how-can-we-transcode-live-rtmp-stream-to-live-hls-stream-using-ffmpeg">answer</a> )</p>
  
  <pre><code>#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;
  }
  
  
  http {
      include       mime.types;
      default_type  application/octet-stream;
  
  
      sendfile        on;
      keepalive_timeout  65;
  
      server {
          listen       8080;
          server_name  localhost;
  
          location / {
              root   html;
              index  index.html index.htm;
          }
  
      location /stat {
              rtmp_stat all;
              rtmp_stat_stylesheet stat.xsl;
          }
  
      location /stat.xsl {
              # you can move stat.xsl to a different location
              root /usr/build/nginx-rtmp-module;
          }
  
          # rtmp control
          location /control {
              rtmp_control all;
          }
  
          # Client (VLC etc.) can access HLS here.
          location /hls {
             # Serve HLS fragments
             types {
               application/vnd.apple.mpegurl m3u8;
               video/mp2t ts;
             }
             root /tmp;
             add_header Cache-Control no-cache;
           }
  
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   html;
          }
  
      }
  
  }
  
  rtmp {
          server {
                  listen 1935;
                  chunk_size 4096;
  
                  application live {
                          live on;
                          record off;
                  }
  
                  application directo {
                          live on;
                          record off;
                  }
  
                  # You should send x.264/aac RTMP Stream via ffmpeg to this application
                   application hls {
                     allow play all;
                     live on;
                     hls on;
                     hls_path /tmp/hls;
                   }
          }
  }
  </code></pre>
  
  <p>And this is a capture of the OBS streaming configuration:</p>
  
  <p><a href="https://i.stack.imgur.com/v1u16.png" rel="noreferrer"><img src="https://i.stack.imgur.com/v1u16.png" alt="enter image description here"></a></p>
  
  <p>PC can view the stream just fine, but mobile can't. </p>
  
  <p>Appreciate any input anyone may have.</p>