title: Live Stream using .m3u8 and .ts files with iPhone as server
body: <p>I am trying to accomplish a task to live stream from iPhone camera. I have done some research and found that i can use <code>.m3u8</code> files for streaming live video with should contain .<code>ts(Mpeg-2)</code> files .</p>
  
  <p>Now the file which i have on my iPhone is <code>.mp4</code> file and it does not work with .m3u8, so i figured out i will have to convert <code>.mp4</code> to <code>.ts</code> for that , but i have not succeeded in doing so.</p>
  
  <p>I found that it is possible to convert video <a href="https://github.com/kewlbear/FFmpeg-iOS-build-script" rel="nofollow">ffmpeg lib</a> as mentioned in <a href="http://ubuntuforums.org/showthread.php?t=2003105" rel="nofollow">this article here</a>. I have successfully imported <code>ffmpeg</code> library but not able figure out how can i use it to convert a video as i am using this for first time.</p>
  
  <p>One another thing <a href="https://developer.apple.com/library/ios/documentation/networkinginternet/conceptual/streamingmediaguide/Introduction/Introduction.html" rel="nofollow">apple documentation</a> says</p>
  
  <blockquote>
    <p>There are a number of hardware and software encoders that can create
    MPEG-2 transport streams carrying MPEG-4 video and AAC audio in real
    time.</p>
  </blockquote>
  
  <p>What is being said here? is there any other way i can use .mp4 files for live streaming without converting them from iOS?</p>
  
  <p>Let me know if i am not clear, i can provide more information .Any suggestion is appreciated. I would like to know am i on a right path here?</p>
  
  <p><strong>EDIT</strong></p>
  
  <p>I am adding more info to my question, so basically what i am asking is , we can convert .mp4 video to .ts using following command</p>
  
  <pre><code>ffmpeg -i file.mp4 -acodec libfaac -vcodec libx264 -an -map 0 -f segment -segment_time 10 -segment_list test.m3u8 -segment_format mpegts -vbsf h264_mp4toannexb -flags -global_header stream%05d.ts
  </code></pre>
  
  <p>How can i use ffmpeg library to do what this command does in iOS.</p>