title: HTTP Live Streaming : The Linux nightmare
body: <p>I'm working on a music VOD app on iPhone, and thanks to Apple guidelines, I have to run a HTTP Live Streaming in order to be accepted on the AppStore. But, since Apple doesn't care about 98% of servers on earth, they don't provide their so magical HTTP Live Streaming Tools for Linux-based systems. And from this point, the nightmare starts.</p>
  
  <p>My goal is simple : Take an MP3, segmentate it and generate a simple .m3u8 index file.
  I googled "HTTP Live Streaming Linux" and "Oh great ! lots of people have already done that"!</p>
  
  <p>First, I visited <a href="http://www.ioncannon.net/programming/452/iphone-http-streaming-with-ffmpeg-and-an-open-source-segmenter/" rel="nofollow noreferrer">the (so famous) post by Carson McDonald</a>.
  Result : the svn segmentate.c was old, buggy and a nightmare to compile (Nobody in this world can precise what version of ffmpeg they are using !).
  Then I came across <a href="https://github.com/carsonmcdonald/HTTP-Live-Video-Stream-Segmenter-and-Distributor/tree/v2" rel="nofollow noreferrer">the Carson's git repo</a>, but too bad, there is a lot of annoying ruby stuff and live_segmenter.c can't take mp3 files.</p>
  
  <p>Then I searched more deeply. I found <a href="https://stackoverflow.com/questions/10247789/http-live-streaming-segmenting-mp3-on-linux">this stackoverflow topic</a>, and it's exactly what I want to do. So I have followed the advice from juuni to use <a href="http://code.google.com/p/httpsegmenter/" rel="nofollow noreferrer">this script (httpsegmenter)</a>. Result: Impossible to compile anything, 2 days of works and finally I managed to compile it (ffmpeg 8.1 w/ httpsegmenter rev17). And no, this is not a good script, it does take mp3 files, but the ts files generated and the index file can't be read by a player.</p>
  
  <p>Then the author of the post krisbulman, came with a solution, and even gave a patched version of m3u8-segmenter by his own (<a href="http://github.com/krisbulman/m3u8-segmenter" rel="nofollow noreferrer">git repo</a>). I test it : doesn't compile, do nothing. So I took the original version from johnf <a href="https://github.com/johnf/m3u8-segmenter" rel="nofollow noreferrer">https://github.com/johnf/m3u8-segmenter</a>. I managed to compile and miracle it works (not really). 
  I used this command line (ffmpeg 0.8.1):</p>
  
  <pre><code>ffmpeg -er 4 -i music.mp3 -f mpegts -acodec libmp3lame -ar 44100 -ab 128k -vn - | m3u8-segmenter -i - -d 10 -p outputdir/prefix -m outputdir/output.m3u8 -u http://test.com/
  </code></pre>
  
  <p>This script encode my mp3 file (it takes 4 seconds, too long), and pass it to the m3u8-segmenter to segment it into 10 seconds .TS files.</p>
  
  <p>I tested this stream with Apple's mediastreamvalidator on my mac, and it said that it was OK. So i played it into quicktime, but there is about 0.2 seconds blank between each .TS files !!</p>
  
  <p>So here is my situation, it's a nightmare, I can't get a simple mp3 stream over the HLS protocol. Is there a simple WORKING solution to segmentate a mp3 ? Why can't I directly segmentate the mp3 file into multiple mp3 files like Apple's mediafilesegmenter does?</p>