SpatialVideoDataset_split / download_all.py
MochuXiang's picture
download and process tools
6843b9b verified
import os
import requests
from concurrent.futures import ThreadPoolExecutor, as_completed
BASE_URL = "https://ftp.itec.aau.at/datasets/SVD/AVP/"
OUTPUT_DIR = "./videos"
NUM_WORKERS = 32
os.makedirs(OUTPUT_DIR, exist_ok=True)
def download_file(file_id: int):
file_name = f"{file_id:04d}.mov"
url = f"{BASE_URL}{file_name}"
output_path = os.path.join(OUTPUT_DIR, file_name)
try:
# Stream download
with requests.get(url, stream=True, timeout=30) as r:
r.raise_for_status()
with open(output_path, "wb") as f:
for chunk in r.iter_content(chunk_size=8192):
if chunk:
f.write(chunk)
return f"✅ {file_name} downloaded"
except Exception as e:
return f"❌ {file_name} failed: {e}"
def main():
file_ids = range(1, 160) # 0001 to 0159
results = []
with ThreadPoolExecutor(max_workers=NUM_WORKERS) as executor:
future_to_file = {executor.submit(download_file, fid): fid for fid in file_ids}
for future in as_completed(future_to_file):
print(future.result())
if __name__ == "__main__":
main()