MochuXiang's picture
download and process tools
6843b9b verified
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()