-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvidcvt.py
executable file
·94 lines (74 loc) · 2.09 KB
/
vidcvt.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/env python
import os, sys, glob, getopt
from colorama import init, Fore, Back
from pprint import pprint
import ffmpeg
import subprocess
import shutil
from proclib import prun, splitnonalpha, getID, procTime, getFilesize
import time
from colorama import Fore, init
import proclib as p
import procvars as g
init()
timestamp = round(time.time())
def showhelp():
print("help")
rs = '''
-h, --help show help
-a, --adjust gamma, contrast, brightness, saturation ex: "1.2:::"
-f, --file filename
'''
print(rs)
exit()
locationpath = os.getcwd()
dirname = os.getcwd()
basename = False
verbose = False
srcfile = False
testonly = False
adj_gamma = 1.2
adj_brightness = 0.1
adj_saturation=1.2
adj_contrast=1.2
if len(sys.argv) == 0:
showhelp()
#^ if there is only one argument with no flags, then assume it is a filename
pprint(sys.argv)
argv = sys.argv[1:]
try:
opts, args = getopt.getopt(argv, "hf:a:g:b:c:s:", [
"help",
"filename=",
"adjust=",
"gamma=",
"brightness=",
"saturation=",
"contrast=",
])
except Exception as e:
p.errprint(str(e))
for opt, arg in opts:
if opt in ("-h", "--help"):
showhelp();
if opt in ("-f", "--filename"):
locationpath = arg;
if opt in ("-g", "--gamma"):
adj_gamma = float(arg)
if opt in ("-b", "--brightness"):
adj_brightness = float(arg)
if opt in ("-s", "--saturation"):
adj_saturation = float(arg)
if opt in ("-c", "--contrast"):
adj_contrast = float(arg)
basename,dirname,fspec,srcfile = p.getFnames(locationpath)
srcfile = f"{dirname}/{basename}"
print(f"dirname: {dirname}")
print(f"basename: {basename}")
print(f"srcfile:{srcfile}")
print(f"fspec:{fspec}")
id = getID(basename)
destname = f"{dirname}/adj_{basename}"
destname = destname.replace(".avi",".mp4")
cmd = f"ffmpegC -y -loglevel panic -i {srcfile} -vf eq=gamma={adj_gamma}:contrast={adj_contrast}:brightness={adj_brightness}:saturation={adj_saturation} {destname}"
p.prun(cmd,debug=True)