title: Playing m3u8 Files with HTML Video Tag
body: <p>I am trying to use HTTP Live Streaming (HLS) to stream video to my computers and my iPhone.  After reading through the Apple 'HTTP Live Streaming Overview' as well as 'Best Practices for Creating and Deploying HTTP Live Streaming Media for the iPhone and iPad', I am a bit stuck.</p>
  
  <p>I took my source file (an mkv) and used ffmpeg to encode the file the MPEG-TS format and Apple-recommended settings and a Baseline 3.0 profile:</p>
  
  <pre><code>ffmpeg -i "example.mkv" -f mpegts -threads:v 4 -sws_flags bicubic -vf "scale=640:352,setdar=16/9,ass=sub.ass" -codec:v libx264 -r 29.970 -b:v 1200k -profile:v baseline -level:v 3.0 -movflags faststart -coder 1 -flags +loop -cmp chroma -partitions +parti8x8+parti4x4+partp8x8+partb8x8 -me_method hex -subq 6 -me_range 16 -g 239 -keyint_min 25 -sc_threshold 40 -i_qfactor 0.71 -b_strategy 1 -qcomp 0.6 -qmin 10 -qmax 51 -qdiff 4 -direct-pred 1 -fast-pskip 1 -af "aresample=48000" -codec:a libvo_aacenc -b:a 96k -ac 2  -y "output.ts"
  </code></pre>
  
  <p>No worries there.  I used a <a href="https://code.google.com/p/httpsegmenter/" rel="noreferrer">pre-compiled segmenting tool</a> to segment the video and build a .m3u8 playlist.  The resultant file looked like this:</p>
  
  <pre><code>#EXTM3U
  #EXT-X-TARGETDURATION:10
  #EXTINF:10,
  http://localhost/media/stream/stream-1.ts
  #EXTINF:10,
  http://localhost/media/stream/stream-2.ts
  #EXTINF:10,
  http://localhost/media/stream/stream-3.ts
  #EXT-X-ENDLIST
  </code></pre>
  
  <p>I checked that against some <a href="https://developer.apple.com/library/ios/technotes/tn2288/_index.html" rel="noreferrer">Example Playlist Files for use with HTTP Live Streaming</a>, and I don't see any issues.  I also tried playing the .m3u8 file in VLC, and it works like a charm.</p>
  
  <p>I created an HTML page to play the file:</p>
  
  <pre><code>&lt;html lang="en"&gt;
      &lt;head&gt;
          &lt;meta charset=utf-8/&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;div id='player'&gt;
              &lt;video width="352" height="288" src="stream.m3u8" controls autoplay&gt;
              &lt;/video&gt;
          &lt;/div&gt;
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>And this page does not work in Chrome, Safari, on my iPhone.  The html5 video tag examples on w3schools work fine on my computer, and the official Apple overview mentioned above gives an HTML example very similar to my page.  Nevertheless, my video player is completely unresponsive when I visit my own .m3u8 page.</p>