[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.)
  Like:
  https://s2.content.video.llnw.net/smedia/42f4e71183054396907c0dea18241568/Ks/l56Xl_JnkEU-hQoz9-AHS5lrBjICWHZV0dybQSN3w/francstireurs_entrevue_ep472_seq24.mpegts/playlist-933ef269e85350d026f5e55af66a76a52737ff48.m3u8

- 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.

Cheers,
Moritz


More information about the ffmpeg-user mailing list