zmwangx / caterpillar

Hardened HLS merger
MIT License
51 stars 9 forks source link

Downloading from local m3u8 files #1

Closed elmateo487 closed 5 years ago

elmateo487 commented 5 years ago

Hey,

Looking to try out this implementation, but I am unable to download from a local m3u8 file that contains remote links. I don't see a way to point to a local file.

Any ideas?

The reason why I am looking for this is I am trying to remove the intro video from a remote playlists, so I save the playlist and edit it.

Thanks!

zmwangx commented 5 years ago

a local m3u8 file that contains remote links

I don't see a way to point to a local file.

Those descriptions sound pretty confusing. Please include an example.

Also, it sounds like this is just a question that has nothing to do with my project? Please use StackOverflow for that.

elmateo487 commented 5 years ago

This has to do with your project. I see no way to use a m3u8 file locally stored on a machine, instead of stored on a server. Your software requires it to be downloaded via http, or at least it seems.

I have included a renamed to .txt, m3u8 file example. example.txt

Your software can't download from a file stored locally on your machine. Don't know how to better explain that.

zmwangx commented 5 years ago

This has to do with your project. I see no way to use a m3u8 file locally stored on a machine, instead of stored on a server.

Sure, misunderstood.

Your software requires it to be downloaded via http, or at least it seems.

Yeah, This is an HLS (HTTP live Streaming) client, and guess what, HTTP Live Streaming requires HTTP...

When you serve it over HTTP it's totally fine:

$ caterpillar http://127.0.0.1:8080/example.txt
[######################################################################################################################################################] 22/22
...

Although I should point out that your first segment can't be decoded. Maybe an ~encoded~ encrypted (excuse the typo) playlist? Not sure.


And you may ask: how do I serve it locally? There are myriad ways to spin up a temporary HTTP server. E.g., Python has it builtin:

$ python3 -m http.server

See https://docs.python.org/3/library/http.server.html.

I also use this Node http-server and like it.

Closing the issue, but feel free to ask if the explanation isn't clear enough.

elmateo487 commented 5 years ago

Sure, I understand how to serve the file up myself. This is mostly an enhancement idea, as nearly all solutions like this, FFmpeg included, don't need m3u8 files to be served via http, they can be served locally from a file system. If this is just merging HLS portions, the files are downloaded from the links in the m3u8 using the params inside the m3u8. All information needed to do this is inside the m3u8 and doesn't require the m3u8 to live on a server.

Unfortunately, dev FFmpeg has discontinuity issues. Which is why I wanted to try this.

zmwangx commented 5 years ago

Okay, thanks for the suggestion, but local M3U8 files are pretty limited, and I don't have a use case for that, so I'm gonna keep my tool at the HLS level. You can take any code you want since the project is MIT-licensed.

Also, unrelated, but it seems that you're trying to scrape a TV streaming service? It probably won't work because they typically use AES encryption or other DRM schemes (an obvious example being Adobe Access), so unless you break the DRM, the segments you download are useless. In the particular example you gave, even if my tool supported local M3U8 files, it wouldn't have gotten you anywhere due to encryption.

elmateo487 commented 5 years ago

Thanks,

I redacted the AES key from the example, HLS streams can be decrypted down into a video segments if you have the keys. Once decrypted the individual pieces can be stored however you like.

Anyways, thanks! Have a good one.

zmwangx commented 5 years ago

HLS streams can be decrypted down into a video segments if you have the keys.

Yeah, if you have the key then great, but my tool doesn't do decoding for you, so you need to download all the individual segments, decode them, then my code could kick in. The code you would be interested in is merge.py, which works on strictly local playlists and segments.