forked from kieranjol/IFIscripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
qctools.py
executable file
·55 lines (44 loc) · 2.03 KB
/
qctools.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
#!/usr/bin/env python
import subprocess
import sys
import os
from glob import glob
def make_qctools(input):
qctools_args = ['ffprobe', '-f', 'lavfi', '-i',]
qctools_args += ["movie=%s:s=v+a[in0][in1],[in0]signalstats=stat=tout+vrep+brng,cropdetect=reset=1:round=1,idet=half_life=1,split[a][b];[a]field=top[a1];[b]field=bottom,split[b1][b2];[a1][b1]psnr[c1];[c1][b2]ssim[out0];[in1]ebur128=metadata=1,astats=metadata=1:reset=1:length=0.4[out1]" % input]
qctools_args += ['-show_frames', '-show_versions', '-of', 'xml=x=1:q=1', '-noprivate']
print qctools_args
qctoolsreport = subprocess.check_output(qctools_args)
return qctoolsreport
def write_qctools_gz(qctoolsxml, sourcefile):
with open(qctoolsxml, "w+") as fo:
fo.write(make_qctools(sourcefile))
subprocess.call(['gzip', qctoolsxml])
input = sys.argv[1]
print input
# Store the directory containing the input file/directory.
wd = os.path.dirname(input)
# Change current working directory to the value stored as "wd"
os.chdir(os.path.abspath(wd))
# Store the actual file/directory name without the full path.
file_without_path = os.path.basename(input)
print file_without_path
# Check if input is a file.
# AFAIK, os.path.isfile only works if full path isn't present.
if os.path.isfile(file_without_path):
print os.path.isfile(file_without_path)
print "single file found"
video_files = [] # Create empty list
video_files.append(file_without_path) # Add filename to list
print video_files
# Check if input is a directory.
elif os.path.isdir(file_without_path):
os.chdir(file_without_path)
video_files = glob('*.mov') + glob('*.mp4') + glob('*.mxf') + glob('*.mkv') + glob('*.avi') + glob('*.y4m')
# Prints some stuff if input isn't a file or directory.
else:
print "Your input isn't a file or a directory."
print "What was it? I'm curious."
for filename in video_files: #loop all files in directory
qctoolsxml_file = filename + '.qctools.xml'
write_qctools_gz(qctoolsxml_file, filename)