|
import os |
|
import shutil |
|
import zipfile |
|
|
|
|
|
dataset_root = "./frames" |
|
|
|
def zip_and_unzip_videos(dataset_root): |
|
for split in os.listdir(dataset_root): |
|
print('Unzipping {} videos'.format(split)) |
|
split_root = os.path.join(dataset_root, split) |
|
for video_dataset in os.listdir(split_root): |
|
if not video_dataset.endswith('.zip'): |
|
continue |
|
print('\tExtracting {}...'.format(video_dataset), end=' ') |
|
video_dataset_root = os.path.join(split_root, video_dataset.replace('.zip', '')) |
|
|
|
|
|
zip_filename = video_dataset |
|
zip_filepath = os.path.join(split_root, zip_filename) |
|
|
|
with zipfile.ZipFile(zip_filepath, 'r') as zipf: |
|
zipf.extractall(video_dataset_root) |
|
|
|
os.remove(zip_filepath) |
|
print('Done!') |
|
|
|
|
|
zip_and_unzip_videos(dataset_root) |