title: How to download .m3u8 in once time
body: <p>I have a <code>.m3u8</code> file on remote host, with contain fixed numbers of chunk <code>.ts</code> file name, and not stream:</p>
  
  <pre><code>#EXTM3U
  #EXT-X-VERSION:3
  #EXT-X-TARGETDURATION:11
  #EXT-X-MEDIA-SEQUENCE:0
  #EXTINF:9.736,
  media_0.ts
  #EXTINF:9.96,
  media_1.ts
  #EXTINF:10.0,
  media_2.ts
  #EXTINF:10.0,
  media_3.ts
  #EXTINF:10.0,
  media_4.ts
  #EXTINF:10.2,
  media_5.ts
  #EXTINF:10.0,
  </code></pre>
  
  <p>When I use this command:</p>
  
  <pre><code># ffmpeg -i "http://example.com/chunklist.m3u8" file.mp4
  
  frame=  582 fps=9.4 q=28.0 size=    1536kB time=00:00:23.21 bitrate= 542.1kbits/s dup=2 drop=4 speed=0.375x
  </code></pre>
  
  <p>It works. But It get frame by frame video and very long time needed. (It takes time almost to playback the video.)</p>
  
  <p>But since the path of all the <code>.ts</code> files are known. (<a href="http://example.com/media_0.ts" rel="noreferrer">http://example.com/media_0.ts</a>, <a href="http://example.com/media_1.ts" rel="noreferrer">http://example.com/media_1.ts</a>, ...) There must be a way to get and merge them all at the same time.</p>
  
  <p>But How in <a href="http://ffmpeg.org/" rel="noreferrer"><code>ffmpeg</code></a> directly?!</p>
  
  <h3>EDIT (try a solution):</h3>
  
  <p>For one solution, I know how can concatenation files with ffmpeg.</p>
  
  <pre><code>ffmpeg -i "concat:0.ts|1.ts|2.ts|3.ts|4.ts|5.ts" -c copy output.mp4
  </code></pre>
  
  <p>This ffmpeg command was great, and works in less 1 sec time!</p>
  
  <p>So try to download all <code>.ts</code> files with CURL with this command:</p>
  
  <pre><code>curl \
  http://example.com/media_0.ts -o 0.ts \
  http://example.com/media_1.ts -o 1.ts \
  http://example.com/media_2.ts -o 2.ts \
  http://example.com/media_3.ts -o 3.ts \
  http://example.com/media_4.ts -o 4.ts \
  http://example.com/media_5.ts -o 5.ts
  </code></pre>
  
  <p>But you can see result:</p>
  
  <pre><code>  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                   Dload  Upload   Total   Spent    Left  Speed
  100  687k  100  687k    0     0  75108      0  0:00:09  0:00:09 --:--:-- 74111
  100  652k  100  652k    0     0  59404      0  0:00:11  0:00:11 --:--:-- 53400
  100  673k  100  673k    0     0  48675      0  0:00:14  0:00:14 --:--:-- 55781
  100  657k  100  657k    0     0  63573      0  0:00:10  0:00:10 --:--:-- 62494
  100  671k  100  671k    0     0  39019      0  0:00:17  0:00:17 --:--:-- 40863
  100  692k  100  692k    0     0  63480      0  0:00:11  0:00:11 --:--:-- 80049
  </code></pre>
  
  <p>See, total download time was 72 sec, while the total duration of all parts is 59 sec! that this time is very long!</p>
  
  <p>So sorry, download all parts and then concat that, was not good solution.</p>
  
  <h3>EDIT 2</h3>
  
  <p>I try for another <code>.m3u8</code> file on the another server with difference URL:</p>
  
  <p>Download and concat together:</p>
  
  <pre><code>ffmpeg -i "concat:\
  http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_0.ts|\
  http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_1.ts|\
  http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_2.ts|\
  http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_3.ts|\
  http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_4.ts|\
  http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_5.ts\
  " -c copy -y output.ts
  </code></pre>
  
  <p>Another command with <code>input.txt</code> URLs file.</p>
  
  <pre><code>ffmpeg -f "concat" -i "input.txt" -c copy -y output.ts
  </code></pre>
  
  <p>input.txt file:</p>
  
  <pre><code>file 'http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_0.ts'
  file 'http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_1.ts'
  file 'http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_2.ts'
  file 'http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_3.ts'
  file 'http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_4.ts'
  file 'http://184.72.239.149/vod/smil:BigBuckBunny.smil/media_w442897525_b560000_5.ts'
  </code></pre>
  
  <p>Or this command some time if needed:</p>
  
  <pre><code>ffmpeg -f "concat" -safe "0" -protocol_whitelist "file,http,https,tcp,tls" -i "input.txt" -c copy -y output.ts
  </code></pre>
  
  <p>Finally, for that download speed was good, <strong>MAYBE my server target has limited bandwidth. :-(</strong></p>