Datasets:
WesleyHsieh0806
commited on
Commit
·
0dc8bfb
1
Parent(s):
2bf8dd8
unzip videos
Browse files- unzip_video.py +24 -0
unzip_video.py
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import os
|
2 |
+
import shutil # For zip creation and extraction
|
3 |
+
import zipfile
|
4 |
+
|
5 |
+
|
6 |
+
dataset_root = "/compute/trinity-1-38/chengyeh/TAO/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 |
+
video_dataset_root = os.path.join(split_root, video_dataset)
|
13 |
+
# *** Unzipping ***
|
14 |
+
# *** Zipping ***
|
15 |
+
zip_filename = video_dataset + '.zip'
|
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(split_root) # Extract to the split folder
|
20 |
+
|
21 |
+
os.remove(zip_filepath)
|
22 |
+
|
23 |
+
# Call the function to perform zipping and unzipping
|
24 |
+
zip_and_unzip_videos(dataset_root)
|