Datasets:
chengyenhsieh
commited on
Update unzip_video.py
Browse files- unzip_video.py +8 -3
unzip_video.py
CHANGED
@@ -7,18 +7,23 @@ dataset_root = "./frames"
|
|
7 |
|
8 |
def zip_and_unzip_videos(dataset_root):
|
9 |
for split in os.listdir(dataset_root):
|
|
|
10 |
split_root = os.path.join(dataset_root, split)
|
11 |
for video_dataset in os.listdir(split_root):
|
12 |
-
|
|
|
|
|
|
|
13 |
# *** Unzipping ***
|
14 |
# *** Zipping ***
|
15 |
-
zip_filename = video_dataset
|
16 |
zip_filepath = os.path.join(split_root, zip_filename) # Zip in the split folder
|
17 |
|
18 |
with zipfile.ZipFile(zip_filepath, 'r') as zipf:
|
19 |
-
zipf.extractall(
|
20 |
|
21 |
os.remove(zip_filepath)
|
|
|
22 |
|
23 |
# Call the function to perform zipping and unzipping
|
24 |
zip_and_unzip_videos(dataset_root)
|
|
|
7 |
|
8 |
def zip_and_unzip_videos(dataset_root):
|
9 |
for split in os.listdir(dataset_root):
|
10 |
+
print('Unzipping {} videos'.format(split))
|
11 |
split_root = os.path.join(dataset_root, split)
|
12 |
for video_dataset in os.listdir(split_root):
|
13 |
+
if not video_dataset.endswith('.zip'):
|
14 |
+
continue
|
15 |
+
print('\tExtracting {}...'.format(video_dataset), end=' ')
|
16 |
+
video_dataset_root = os.path.join(split_root, video_dataset.replace('.zip', ''))
|
17 |
# *** Unzipping ***
|
18 |
# *** Zipping ***
|
19 |
+
zip_filename = video_dataset
|
20 |
zip_filepath = os.path.join(split_root, zip_filename) # Zip in the split folder
|
21 |
|
22 |
with zipfile.ZipFile(zip_filepath, 'r') as zipf:
|
23 |
+
zipf.extractall(video_dataset_root) # Extract to the split folder
|
24 |
|
25 |
os.remove(zip_filepath)
|
26 |
+
print('Done!')
|
27 |
|
28 |
# Call the function to perform zipping and unzipping
|
29 |
zip_and_unzip_videos(dataset_root)
|