[FFmpeg-user] How to download the ts files from .m3u8 playlist

Moritz Barsnick barsnick at gmx.net
Fri Apr 27 16:46:15 EEST 2018

On Fri, Apr 27, 2018 at 18:54:40 +0530, m.kamalasubha m.kamalasubha wrote:
> Is there any way to download the individual ts files from the .m3u8
> playlist file https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8 of
> specific bitrate using FFmpeg?

No, ffmpeg always demuxes and remuxes a stream.

What you can do is to use youtube-dl to download and reassemble the
segments. You need to use options like "--hls-prefer-native" and
especially "--fixup never". (This probably only works correctly with
MPEG-TS HLS, I don't have experience with MPEG4 HLS.) Note that
youtube-dl will name the file ".mp4", even if it is MPEG-TS.

Two additional remarks:
- Your given URL doesn't hold .ts segments, it is rather a "playlist"
  of further .m3u8 URLs. (youtube-dl can handle that, too.)

- The (final) m3u8 is actually a list of .ts segments. You could
  download them yourself, and simply concatentate them in the correct
  order. That said, youtube-dl does a very much better job of this,
  no reason to reinvent the wheel, unless you need to work on an
  embedded platform (which may be too weak for youtube-dl). youtube-dl
  also handles decryption, IIUC, something not easily done manually.


More information about the ffmpeg-user mailing list