Discussion:
[FFmpeg-user] How to download the ts files from .m3u8 playlist
m.kamalasubha m.kamalasubha
2018-04-27 13:24:40 UTC
Permalink
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user
Moritz Barsnick
2018-04-27 13:46:15 UTC
Permalink
Post by m.kamalasubha m.kamalasubha
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with
m.kamalasubha m.kamalasubha
2018-04-27 14:11:47 UTC
Permalink
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?
Post by Moritz Barsnick
Post by m.kamalasubha m.kamalasubha
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.
- Your given URL doesn't hold .ts segments, it is rather a "playlist"
of further .m3u8 URLs. (youtube-dl can handle that, too.)
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
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
To unsubscribe, visit link above, or email
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsub
Moritz Barsnick
2018-04-27 15:40:01 UTC
Permalink
Post by m.kamalasubha m.kamalasubha
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-reque
m.kamalasubha m.kamalasubha
2018-04-30 08:41:32 UTC
Permalink
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubsc
Moritz Barsnick
2018-04-30 11:21:40 UTC
Permalink
Post by m.kamalasubha m.kamalasubha
I tried the above command line. It works.
Nice!
Post by m.kamalasubha m.kamalasubha
But the requirement is to have individual raw files for every individual ts
file.
Again, you didn't say so originally.
Post by m.kamalasubha m.kamalasubha
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org
Carl Eugen Hoyos
2018-04-30 18:07:00 UTC
Permalink
Post by Moritz Barsnick
$ 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.)
Post by Moritz Barsnick
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsub
Carl Eugen Hoyos
2018-04-30 18:08:18 UTC
Permalink
Post by Carl Eugen Hoyos
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
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscr

Continue reading on narkive:
Loading...