File size: 1,351 Bytes
6843b9b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
import os
from concurrent.futures import ThreadPoolExecutor, as_completed

WORKERS = 4
START_IDX, END_IDX = 1, 159

def process(idx: int):
    mov_file = f'videos/{idx:04d}.mov'

    try:
        # 1. Split with spatial-media-kit-tool
        os.system(f'./spatial-media-kit-tool --input-file {mov_file} --output-dir tmp')

        # 2. Encode LEFT eye
        os.system(
            f'ffmpeg -y -i tmp/{idx:04d}_LEFT.mov '
            f'-c:v h264_videotoolbox -b:v 8M -an '
            f'split/{idx:04d}_LEFT.mp4'
        )

        # 3. Encode RIGHT eye
        os.system(
            f'ffmpeg -y -i tmp/{idx:04d}_RIGHT.mov '
            f'-c:v h264_videotoolbox -b:v 8M -an '
            f'split/{idx:04d}_RIGHT.mp4'
        )

        # 4. Cleanup intermediate files
        os.system(f'rm -f tmp/{idx:04d}_LEFT.mov tmp/{idx:04d}_RIGHT.mov')

        return f"✅ Finished {idx:04d}"
    except Exception as e:
        return f"❌ Failed {idx:04d}: {e}"

def main():
    os.makedirs("split", exist_ok=True)
    os.makedirs("tmp", exist_ok=True)

    indices = range(START_IDX, END_IDX + 1)

    with ThreadPoolExecutor(max_workers=WORKERS) as executor:
        futures = {executor.submit(process, idx): idx for idx in indices}
        for future in as_completed(futures):
            print(future.result())

if __name__ == "__main__":
    main()