Skip to content

Instantly share code, notes, and snippets.

@flavioribeiro
Created January 28, 2021 15:44
Show Gist options
  • Save flavioribeiro/9b52c603c70cdb34c6910c1c5c4d240d to your computer and use it in GitHub Desktop.
Save flavioribeiro/9b52c603c70cdb34c6910c1c5c4d240d to your computer and use it in GitHub Desktop.
SCTE-35 PID presence on HLS TS Segments
import datetime
import os
from concurrent.futures import ThreadPoolExecutor
from requests import get
import m3u8
from threefive import decode
import time
PLAYLIST = ""
downloader = ThreadPoolExecutor(max_workers=10)
def download(uri, output_dir):
date = datetime.datetime.now().strftime("%Y_%m_%d_%H_%M_%S")
file_path = os.path.join(output_dir, date + "_" + uri.split('/')[-1])
with open(file_path, "wb") as f:
response = get(uri)
f.write(response.content)
print("decoding ", file_path)
decode(file_path)
if __name__ == "__main__":
while True:
master_manifest = m3u8.load(PLAYLIST)
for manifest in master_manifest.playlists:
rendition_manifest = m3u8.load(manifest.absolute_uri)
for segment in rendition_manifest.segments:
downloader.submit(download, segment.absolute_uri, "/tmp/")
time.sleep(6)
@futzu
Copy link

futzu commented Sep 15, 2021

I only did the issue. .I know my issue and how to solve it, but I just don't know the m3u8 code well enough.

@futzu
Copy link

futzu commented Sep 15, 2021

Ill do a pull request, give me a minute,

@futzu
Copy link

futzu commented Sep 16, 2021

hey man. m3u8 needs a little love. I forked it. If you want, I'll add you the repo. Let's collaborate.

@flavioribeiro
Copy link
Author

hey @futzu, m3u8 is actually pretty active, with a lot of people using it.. I think we can suggest things there and implement some PRs. What do you think? Also, if you want a more dynamic conversation, join http://video-dev.org, I'll be there!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment