7

I have an M3U8 file saved locally.

How can I download the video from this file?

M. Justin
  • 293

1 Answers1

10

The movie can be easily downloaded using the FFmpeg command line tool:

ffmpeg -protocol_whitelist file,http,https,tcp,tls,crypto -i my_movie.m3u8 -c copy my_movie.ts

Note that if the .m3u8 file was downloaded from the Internet and contains relative URLs, those URLs will need to be converted to absolute URLs. For example, seg-1-v1-a1.tshttp://videosource.site/seg-1-v1-a1.ts. Since .m3u8 is a textual format, one option would be to find/replace those values, either from the command line or a text editor.

M. Justin
  • 293
  • 8
    You can actually use the Internet URL to the M3U8 file as the input: ffmpeg -i "http://videosource.site/video.m3u8" output.ts. FFMpeg will automatically work out the URLs for each individual file and download them. – Haxiel Jan 24 '22 at 09:03
  • 5
    You forgot to include instructions on how to convert the created .ts file into a playable video, i.e.

    ffmpeg -i input.ts -map 0 -c copy output.mkv

    – Raleigh L. Aug 19 '22 at 02:43
  • What should I do if ffmpeg throws me the following error: "error reading header ... Not yet implemented in FFmpeg, patches welcome" ? @M. Justin – jeppoo1 Jan 05 '23 at 14:03
  • @jeppoo1 I'd say, make sure you have the latest FFmpeg, and if it still fails, file a bug report per https://ffmpeg.org/bugreports.html. – M. Justin Jan 05 '23 at 17:57
  • 1
    @RaleighL. "You forgot to include instructions on how to convert the created .ts file into a playable video" — I wouldn't say "forgot", since the goal here was to download a full offline copy of the video, not to change the format of the video to something more easily playable locally. – M. Justin Jan 08 '24 at 22:25