MochuXiang commited on
Commit
6843b9b
·
verified ·
1 Parent(s): 100b8c4

download and process tools

Browse files
Files changed (4) hide show
  1. .gitattributes +1 -0
  2. download_all.py +38 -0
  3. process.py +47 -0
  4. spatial-media-kit-tool +3 -0
.gitattributes CHANGED
@@ -57,3 +57,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
 
 
57
  # Video files - compressed
58
  *.mp4 filter=lfs diff=lfs merge=lfs -text
59
  *.webm filter=lfs diff=lfs merge=lfs -text
60
+ spatial-media-kit-tool filter=lfs diff=lfs merge=lfs -text
download_all.py ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import requests
3
+ from concurrent.futures import ThreadPoolExecutor, as_completed
4
+
5
+ BASE_URL = "https://ftp.itec.aau.at/datasets/SVD/AVP/"
6
+ OUTPUT_DIR = "./videos"
7
+ NUM_WORKERS = 32
8
+
9
+ os.makedirs(OUTPUT_DIR, exist_ok=True)
10
+
11
+ def download_file(file_id: int):
12
+ file_name = f"{file_id:04d}.mov"
13
+ url = f"{BASE_URL}{file_name}"
14
+ output_path = os.path.join(OUTPUT_DIR, file_name)
15
+
16
+ try:
17
+ # Stream download
18
+ with requests.get(url, stream=True, timeout=30) as r:
19
+ r.raise_for_status()
20
+ with open(output_path, "wb") as f:
21
+ for chunk in r.iter_content(chunk_size=8192):
22
+ if chunk:
23
+ f.write(chunk)
24
+ return f"✅ {file_name} downloaded"
25
+ except Exception as e:
26
+ return f"❌ {file_name} failed: {e}"
27
+
28
+ def main():
29
+ file_ids = range(1, 160) # 0001 to 0159
30
+ results = []
31
+
32
+ with ThreadPoolExecutor(max_workers=NUM_WORKERS) as executor:
33
+ future_to_file = {executor.submit(download_file, fid): fid for fid in file_ids}
34
+ for future in as_completed(future_to_file):
35
+ print(future.result())
36
+
37
+ if __name__ == "__main__":
38
+ main()
process.py ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ from concurrent.futures import ThreadPoolExecutor, as_completed
3
+
4
+ WORKERS = 4
5
+ START_IDX, END_IDX = 1, 159
6
+
7
+ def process(idx: int):
8
+ mov_file = f'videos/{idx:04d}.mov'
9
+
10
+ try:
11
+ # 1. Split with spatial-media-kit-tool
12
+ os.system(f'./spatial-media-kit-tool --input-file {mov_file} --output-dir tmp')
13
+
14
+ # 2. Encode LEFT eye
15
+ os.system(
16
+ f'ffmpeg -y -i tmp/{idx:04d}_LEFT.mov '
17
+ f'-c:v h264_videotoolbox -b:v 8M -an '
18
+ f'split/{idx:04d}_LEFT.mp4'
19
+ )
20
+
21
+ # 3. Encode RIGHT eye
22
+ os.system(
23
+ f'ffmpeg -y -i tmp/{idx:04d}_RIGHT.mov '
24
+ f'-c:v h264_videotoolbox -b:v 8M -an '
25
+ f'split/{idx:04d}_RIGHT.mp4'
26
+ )
27
+
28
+ # 4. Cleanup intermediate files
29
+ os.system(f'rm -f tmp/{idx:04d}_LEFT.mov tmp/{idx:04d}_RIGHT.mov')
30
+
31
+ return f"✅ Finished {idx:04d}"
32
+ except Exception as e:
33
+ return f"❌ Failed {idx:04d}: {e}"
34
+
35
+ def main():
36
+ os.makedirs("split", exist_ok=True)
37
+ os.makedirs("tmp", exist_ok=True)
38
+
39
+ indices = range(START_IDX, END_IDX + 1)
40
+
41
+ with ThreadPoolExecutor(max_workers=WORKERS) as executor:
42
+ futures = {executor.submit(process, idx): idx for idx in indices}
43
+ for future in as_completed(futures):
44
+ print(future.result())
45
+
46
+ if __name__ == "__main__":
47
+ main()
spatial-media-kit-tool ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:efa190f3618f2238b06616442973d086d303628b4835993222c76cd6fc5c52d9
3
+ size 1499752