title: Problem converting RTSP to HLS Nginx to stream
body: <p>I'm really new with <em>nginx</em> and <em>Ubuntu</em>. I'm trying to setup a website to stream an IP Camera Video to the internet. I'm currently using <code>nginx 1.14</code> and <code>ubuntu 18.04</code>.</p>
  <p>I have the <em>RTSP url</em> from the camera and succeed converting it in RTMP with <code>ffmpeg</code> inside my <code>nginx.conf</code> file. I can play the video (both the RTSP and RTMP urls) in VLC without problems.</p>
  <p>My main problem is when I want to convert RTMP to HLS so can play it in a html5 player (like <code>videojs</code>) it doesn't work. Please, see my code below.</p>
  <h2 id="nginx.conf-ppc5">nginx.conf</h2>
  <pre class="lang-bsh prettyprint-override"><code>user www-data;
  worker_processes auto;
  pid /run/nginx.pid;
  include /etc/nginx/modules-enabled/*.conf;
  
  events {
      worker_connections 768;
      # multi_accept on;
  }
  
  rtmp {
      server {
          listen 1935;
          chunk_size 4096;
          
          application live {
              live on;
              record off;
              hls on;
              hls_nested on;
              hls_path /tmp/hls/;
              hls_fragment 3;
              hls_playlist_length 60;
              exec_pull /usr/bin/ffmpeg -i rtsp://025164132:jose1992@192.168.0.16:554/onvif1 -vcodec libx264 -acodec copy -f flv rtmp://192.168.0.14:1935/live/stream1;
          }   
      }
  }
  
  http {
  
      ##
      # Basic Settings
      ##
  
      sendfile on;
      tcp_nopush on;
      tcp_nodelay on;
      keepalive_timeout 65;
      types_hash_max_size 2048;
      # server_tokens off;
  
      # server_names_hash_bucket_size 64;
      # server_name_in_redirect off;
  
      include /etc/nginx/mime.types;
      default_type application/octet-stream;
  
      ##
      # SSL Settings
      ##
  
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
      ssl_prefer_server_ciphers on;
  
      ##
      # Logging Settings
      ##
  
      access_log /var/log/nginx/access.log;
      error_log /var/log/nginx/error.log;
  
      ##
      # Gzip Settings
      ##
  
      gzip on;
  
      # gzip_vary on;
      # gzip_proxied any;
      # gzip_comp_level 6;
      # gzip_buffers 16 8k;
      # gzip_http_version 1.1;
      # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
  
      ##
      # Virtual Host Configs
      ##
  
      include /etc/nginx/conf.d/*.conf;
      include /etc/nginx/sites-enabled/*;
  
      server {     
          listen    80;
  
          location /hls {
              # Serve HLS fragments
  
              # Disable cache
              add_header 'Cache-Control' 'no-cache';
  
              # CORS setup
              add_header 'Access-Control-Allow-Origin' '*' always;
              add_header 'Access-Control-Expose-Headers' 'Content-Length';
  
              # allow CORS preflight requests
              if ($request_method = 'OPTIONS') {
                  add_header 'Access-Control-Allow-Origin' '*';
                  add_header 'Access-Control-Max-Age' 1728000;
                  add_header 'Content-Type' 'text/plain charset=UTF-8';
                  add_header 'Content-Length' 0;
                  return 204;
              }
  
              types {
                  application/dash+xml mpd;
                  application/vnd.apple.mpegurl m3u8;
                  video/mp2t ts;
              }
              root /tmp/;
          }
  
          location / {
              root   html;
              index  index.html index.htm;
          }
  
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   html;
          }
      }
  }
  </code></pre>
  <p>So, when I try to open this url <code>http://ip-server/hls/stream1.m3u8</code> on a browser or VLC instance nothing happens.</p>
  <p>I verified that the <code>.ts</code> and the <code>.m3u8</code> files are being created each time that <em>nginx</em> is running in the folder <code>tmp/hls/stream1/</code> (<code>ts</code> and a <code>index.m3u8</code>) I don't know why the <code>m3u8</code> file is named <code>index</code> instead of <code>stream1</code>.</p>
  <p>Please, if you could help me and correct any of my code if needed. I have been trying for 3 days for this to work but with no luck :(</p>
  <p>Thanks!</p>