-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_all.py
42 lines (32 loc) · 1.32 KB
/
run_all.py
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
import subprocess
from pathlib import Path
from typing import Union
import fire
def main(src_path: Union[str, Path], target: str = "projector"):
"""動画分割
:param Union[str, Path] src_path: 元動画
"""
# パス設定
src_path = Path(src_path)
jpg_dir = src_path.parent.parent / "src_jpg" / src_path.stem
depth_dir = jpg_dir.parent.parent / "depth" / jpg_dir.name
stereo_path = src_path.parent.parent / "3d" / f"{src_path.stem}_nosound{src_path.suffix}"
dst_path = stereo_path.parent / src_path.name
# 前処理
command = f'poetry run python preprocess.py "{src_path}" "{jpg_dir}"'
print(command)
# subprocess.call(command, shell=True)
# depth推定
command = f'poetry run python run_nvds.py "{jpg_dir}" "{depth_dir}"'
print(command)
subprocess.call(command, shell=True)
# 3D動画生成
command = f'poetry run python run_stereo_movie.py -s "{src_path}" -i "{jpg_dir}" -d "{depth_dir}" -o "{stereo_path}" -t {target}'
print(command)
subprocess.call(command, shell=True)
# 音声コピー
command = f'ffmpeg -i "{src_path}" -i "{stereo_path}" -c:v copy -c:a copy -map 0:a -map 1:v "{dst_path}"'
print(command)
subprocess.call(command, shell=True)
if __name__ == "__main__":
fire.Fire(main)