-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocess_video.py
More file actions
78 lines (61 loc) · 1.98 KB
/
process_video.py
File metadata and controls
78 lines (61 loc) · 1.98 KB
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
# felipe whl repo
# https://felipefg.github.io/pip-wheels-riscv/wheels/
# from video_processor import VideoProcessor; VideoProcessor.test()
import os
import sys, getopt
import shutil
from video_processor import VideoProcessor
# main
if __name__ == "__main__":
# parameters
inputfile = None
outputfile = None
fps = None
glasses_path = "data/glasses.png"
play = False
remove = False
debug = False
logging = False
opts, args = getopt.getopt(sys.argv[1:],"hi:o:f:g:prdl",["help","input=","output=","fps=","glasses=","play","rm","debug","logging"])
for opt, arg in opts:
if opt in ('-h', '--help'):
print(f"{sys.argv[0]} --input <inputfile> [options]")
print(f" options: --output=<out path>, --fps=<out video fps>, --glasses=<glasses path>, --play, --rm")
sys.exit()
elif opt in ("-i", "--input"):
inputfile = arg
elif opt in ("-o", "--output"):
outputfile = arg
elif opt in ("-f", "--fps"):
fps = int(arg)
elif opt in ("-g", "--glasses"):
glasses_path = arg
elif opt in ("-r","--rm"):
remove = True
elif opt in ("-p","--play"):
play = True
elif opt in ("-d","--debug"):
debug = True
elif opt in ("-l","--logging"):
logging = True
if inputfile is None:
print(f"Missing input video")
sys.exit(1)
vp = VideoProcessor()
if debug:
vp.debug = True
if logging:
vp.logging = True
# process video
outpath = vp.process_video(inputfile,glasses_path,fps)
if play:
vp.play_video(outpath,fps)
if outputfile is not None:
f, extension = os.path.splitext(outpath)
outputfilepath, e = os.path.splitext(outputfile)
shutil.copyfile(outpath, outputfilepath+extension)
os.unlink(outpath)
outpath = outputfile
if remove:
os.unlink(outpath)
sys.exit()