Last active
April 13, 2022 09:00
-
-
Save burak-kara/c447652d3e8883de82a4f6c9e6af849f to your computer and use it in GitHub Desktop.
Download all possible DASH video and audio segments for different bitrates
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib.request | |
BASE = "https://example.com" | |
bandwidths = [5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100] | |
def download_init(bw): | |
init = "b-1080-" + str(bw) + "mbps_dash_init.mp4" | |
url = BASE + init | |
try: | |
urllib.request.urlretrieve(url, init) | |
except Exception as e: | |
print(e) | |
def download_segments(bw): | |
for number in range(1, 16): | |
media = "b-1080-" + str(bw) + "mbps_dash" | |
media += str(number) + ".m4s" | |
url = BASE + media | |
try: | |
urllib.request.urlretrieve(url, media) | |
except Exception as e: | |
print(e) | |
def download_audio_init(): | |
init = "b-1080-5mbps_dash_track_init.mp4" | |
url = BASE + init | |
try: | |
urllib.request.urlretrieve(url, init) | |
except Exception as e: | |
print(e) | |
def download_audio_segments(): | |
for number in range(1, 16): | |
media = "b-1080-5mbps_dash_track_" | |
media += str(number) + ".m4s" | |
url = BASE + media | |
try: | |
urllib.request.urlretrieve(url, media) | |
except Exception as e: | |
print(e) | |
def get_audio(): | |
download_audio_init() | |
download_audio_segments() | |
def get_video(): | |
for bw in bandwidths: | |
download_segments(bw) | |
download_init(bw) | |
if __name__ == '__main__': | |
get_audio() | |
get_video() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment