selsta / hlsdl

C program to download VoD HLS (.m3u8) files
MIT License
630 stars 158 forks source link

[Feature] Mirror mode #111

Open SebiderSushi opened 3 years ago

SebiderSushi commented 3 years ago

Hello, i am searching for a robust HLS downloader that can mirror HLS playlists, that is download each file necessary for playing or converting it without muxing or recoding anything.

Use case I often download HLS playlists via an instable connection. When saving the stream directly into a muxed file i never encountered a downloader that could easily resume the download when connections fail. This ends up being fatal especially with livestreams. To work around this problem i wrote a couple of scripts to just download all segment files and those mentioned via URIs, like keys. After all fragments are downloaded successfully i convert the local files into whatever i need. This allows me to download VODs or capture streams on a flaky connection without restarting from scratch every minute or so.

On top of this, this method produces a mirror that is less affected by software bugs like those around the discontinuity tag or webVTT subtitles in HLS streams which would lead to corrupted output when directly capturing a livestream with ffmpeg.

Question My solution with scripts is very fragile and doesn't even properly parse the HLS manifests. For example livestreams that wrap their sequence numbers frequently lead to filename collisions since my script does not alter the fragment filenames instead of customizing them by airdate if specified in the manifest while capturing a livestream. Because of this, i am searching for a more robust solution. Do you think a feature like i described would be a feasible & useful addition to hlsdl?