How to download the ts files from .m3u8 playlist

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

How to download the ts files from .m3u8 playlist

m.kamalasubha m.kamalasubha
Hello all,
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?

Thanks,
Kamalasubha M
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

Moritz Barsnick
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
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

m.kamalasubha m.kamalasubha
Hello Moritz,
Thanks for the reply.

Basically, I want to extract the audio and video raw files from the ts
segments of the playlist file. Is it possible to generate the raw files
from the individual TS segments using FFmpeg?

On Fri, Apr 27, 2018 at 7:16 PM Moritz Barsnick <[hidden email]> wrote:

> 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
> _______________________________________________
> ffmpeg-user mailing list
> [hidden email]
> http://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> [hidden email] with subject "unsubscribe".
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

Moritz Barsnick
On Fri, Apr 27, 2018 at 14:11:47 +0000, m.kamalasubha m.kamalasubha wrote:
> Basically, I want to extract the audio and video raw files from the ts
> segments of the playlist file. Is it possible to generate the raw files
> from the individual TS segments using FFmpeg?

Ah, that's why it's always good to explain what you actually intend to
achieve.

ffmpeg can do this, because demuxing actually implies getting the raw
streams out of the video. You don't need the individual segments for
this (unless there's something else you want to do which I don't
understand).

You need to identify the desired streams from the output of this:

$ ffmpeg -i https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8

and then extract them, even several at time, by using the copy codec
and a raw output format, somewhat like this:

$ ffmpeg -i https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8 -map 0:12 -c copy -f rawvideo rawfile.rawh264 -map 0:13 -c copy -f rawvideo rawfile.rawaac

There's no "rawaudio" muxer, but I believe "rawvideo" just leaves any
binary stream untouched, and should be correct. The "aac" muxer OTOH
might be incorrect, as it creates an ADTS stream(??). Anyway, I
confirmed that ffplay can play each of the two resulting raw streams.

Please avoid top-posting,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

m.kamalasubha m.kamalasubha
Hello Moritz,
Thanks for the reply.
I tried the above command line. It works.
But the requirement is to have individual raw files for every individual ts
file.
Is there any way to generate raw file for every ts file?
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

Moritz Barsnick
On Mon, Apr 30, 2018 at 08:41:32 +0000, m.kamalasubha m.kamalasubha wrote:
> I tried the above command line. It works.

Nice!

> But the requirement is to have individual raw files for every individual ts
> file.

Again, you didn't say so originally.

> Is there any way to generate raw file for every ts file?

Sure, but then you obviously need the individual files. As far as I
know, ffmpeg's HLS mechanisms have no way of handling the segments
separately. So, you need to resort to youtube-dl again, and add the
option "--keep-fragments" (and possibly keep the other options I
mentioned). Then you can apply the given ffmpeg raw extaction command
on each individual segment.

Cheers,
Moritz
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

Carl Eugen Hoyos-2
In reply to this post by Moritz Barsnick
2018-04-27 17:40 GMT+02:00, Moritz Barsnick <[hidden email]>:

> $ ffmpeg -i https://mnmedias.api.telequebec.tv/m3u8/29880.m3u8
> -map 0:12 -c copy -f rawvideo rawfile.rawh264 -map 0:13 -c copy
> -f rawvideo rawfile.rawaac
>
> There's no "rawaudio" muxer, but I believe "rawvideo" just leaves
> any binary stream untouched, and should be correct.

True.
(And I hope a currently discussed patch does not break this -
important - feature.)

> The "aac" muxer OTOH might be incorrect, as it creates an
> ADTS stream(??). Anyway, I confirmed that ffplay can play
> each of the two resulting raw streams.

Not true for every input file containing aac, note that FFmpeg cannot
read "raw" aac files, only adts and loas/latm.

(We do read more unusual formats like raw flac though.)

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".
Reply | Threaded
Open this post in threaded view
|

Re: How to download the ts files from .m3u8 playlist

Carl Eugen Hoyos-2
2018-04-30 20:07 GMT+02:00, Carl Eugen Hoyos <[hidden email]>:

> Not true for every input file containing aac, note that FFmpeg cannot
> read "raw" aac files, only adts and loas/latm.

Ticket #2458.

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
[hidden email]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[hidden email] with subject "unsubscribe".