Recent

Author Topic: How to download a video from an URL like *.m3u8 ?  (Read 8442 times)

toby

  • Sr. Member
  • ****
  • Posts: 270
Re: How to download a video from an URL like *.m3u8 ?
« Reply #15 on: April 26, 2024, 11:34:39 pm »
did you get something working?

i use sysutils.executeprocess with yt-dlp
https://github.com/yt-dlp


Hartmut

  • Hero Member
  • *****
  • Posts: 803
Re: How to download a video from an URL like *.m3u8 ?
« Reply #16 on: April 27, 2024, 07:42:50 am »
did you get something working?

i use sysutils.executeprocess with yt-dlp
https://github.com/yt-dlp

Yes, I wrote a small program which can download the single segment files of a m3u8 video and calls ffmpeg to concat them to a video file. If I'll get further problems, I'll give yt-dlp a try. Thank you toby for that suggestion.

toby

  • Sr. Member
  • ****
  • Posts: 270
Re: How to download a video from an URL like *.m3u8 ?
« Reply #17 on: April 27, 2024, 06:41:13 pm »

i assume you are using curl to get the m3u8 to get the urls and number of
fragments and then curl to get the fragments?

sounds like you are doing in fpc what yt-dlp is doing but in python

would you be up to posting the code you have written in fpc?  it would be interesting to test it



this is what yt-dlp is doing (from cli but same with sysutils.executeprocess in fpc)

> yt-dlp https://srf-vod-amd.akamaized.net/ch/hls/film/2024/03/film_20240317_000539_4703373_v_webcast_h264_,q40,q10,q20,q30,q50,q60,.mp4.csmil/index-f1-v1-a1.m3u8
[generic] Extracting URL: https://srf-vod-amd.akamaized.net/ch/hls/film/2024/03/film_20240317_000539_4703373_v_webcast_h264.../index-f1-v1-a1.m3u8
[generic] index-f1-v1-a1: Downloading webpage
[generic] index-f1-v1-a1: Downloading m3u8 information
[generic] index-f1-v1-a1: Checking m3u8 live status
[info] index-f1-v1-a1: Downloading 1 format(s): 0
[hlsnative] Downloading m3u8 manifest
WARNING: Live HLS streams are not supported by the native downloader. If this is a livestream, please add "--downloader ffmpeg --hls-use-mpegts" to your command
[hlsnative] Total fragments: 37
[download] Destination: index-f1-v1-a1 [index-f1-v1-a1].mp4
[download] 100% of   91.77MiB in 00:01:38 at 954.51KiB/s        <-- gets each fragment then gives this total for downloads
[FixupM3u8] Fixing MPEG-TS in MP4 container of "index-f1-v1-a1 [index-f1-v1-a1].mp4"






Hartmut

  • Hero Member
  • *****
  • Posts: 803
Re: How to download a video from an URL like *.m3u8 ?
« Reply #18 on: April 28, 2024, 10:47:31 am »
i assume you are using curl to get the m3u8 to get the urls and number of
fragments and then curl to get the fragments?

No, I use class 'TFPHttpClient' to download each file.

Quote
would you be up to posting the code you have written in fpc?  it would be interesting to test it

I am sorry, no, for two reasons. 1st this program was a quick hack and is no recommendation to publish it. 2nd the program uses several common libraries, which I don't have the rights to publish them.

But if you are deeply interested, I could extract for you 1 procedure (which downloads 1 URL from type *.m3u8 into a small textfile and then extracts all needed segments into an array) and send it by PM to you.

But as said, that procedure would not compile (because of missing libraries) and all comments are in German.

phoenix27

  • Jr. Member
  • **
  • Posts: 91
Re: How to download a video from an URL like *.m3u8 ?
« Reply #19 on: August 14, 2024, 01:18:07 am »
Why don't you show us that routine? Do you want us to reinvent the wheel?

 

TinyPortal © 2005-2018