-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost-process.py
79 lines (75 loc) · 1.56 KB
/
post-process.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import os
import subprocess
from argparse import ArgumentParser
argparser = ArgumentParser(
description="Post-process simulation results, convert png files to video"
)
argparser.add_argument(
"-P",
"--path",
default="ffmpeg",
type=str,
help="ffmpeg to use",
)
argparser.add_argument(
"-R",
"--framerate",
default=30,
type=int,
help="Frames rate (frames per second)",
)
argparser.add_argument(
"-L",
"--loop",
action="store_true",
help="Loop over the input",
)
argparser.add_argument(
"-F",
"--force",
action="store_true",
help="Overwrites existing output files",
)
argparser.add_argument(
"-D",
"--directory",
default="fig",
type=str,
help="Output directory",
)
args = argparser.parse_args()
print(args)
commands = [
args.path,
"-f",
"image2",
"-framerate",
str(args.framerate),
"-i",
os.path.join(args.directory, "frames", "GEN-%d.png"),
"-loop",
str(int(args.loop)),
os.path.join(args.directory, "Population.mp4"),
"-y" if args.force else "",
]
if subprocess.run(commands).returncode == 0:
print("Population done")
else:
print("Population failed")
commands = [
args.path,
"-f",
"image2",
"-framerate",
str(args.framerate),
"-i",
os.path.join(args.directory, "frames", "DIST-%d.png"),
"-loop",
str(int(args.loop)),
os.path.join(args.directory, "Distance.mp4"),
"-y" if args.force else "",
]
if subprocess.run(commands).returncode == 0:
print("Distance done")
else:
print("Distance failed")