-
Notifications
You must be signed in to change notification settings - Fork 13
/
video_maker.py
68 lines (51 loc) · 1.57 KB
/
video_maker.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
import os
from glob import glob
import re
import subprocess
import argparse
def make_videos(files_to_process):
for id in files_to_process:
print("creating %s.mp4" % id)
subprocess.call('./join_videos.sh %s' % id, shell=True)
def main():
parser = argparse.ArgumentParser()
parser.add_argument(
'--view',
'-v',
dest='view',
default=False,
action='store_true',
help="View-only mode - do not process any files")
parser.add_argument(
'--framerate',
'-f',
type=int,
dest='framerate',
default=15,
help='Sets the camera framerate. Default is 15')
args = parser.parse_args()
path = "./recordings"
mp4_files = glob(os.path.join(path, "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*.mp4"))
h264_files = glob(os.path.join(path, "[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]*_*.h264"))
h264_ids = []
to_process = []
for file in mp4_files:
m = re.search(r"([0-9]{10,})", file)
h264_ids.append(m.group(1))
for file in h264_files:
m = re.search(r"([0-9]{10,})_(before|after)(\.h264)", file)
vid = m.group(1)
if vid not in h264_ids:
to_process.append(vid)
to_process = list(set(to_process)) # dedupe
if args.view:
print("Existing videos")
for file in mp4_files:
print(file)
print("Recordings without video")
for file in to_process:
print(file)
else:
make_videos(to_process)
if __name__ == '__main__':
main()