-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
66 lines (56 loc) · 2.89 KB
/
main.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
# -*- coding: utf-8 -*-
import optparse
from probe import HProbe
def probe_url(options, videourl):
if options.b_qp is True:
listQP = HProbe.get_qp(videourl, skip_frame=options.skip_frame, duration_sec=options.duration)
HProbe.print_qp(listQP)
if options.b_nodraw is False:
HProbe.draw_qp(listQP)
if options.b_ci is True:
ci = HProbe.get_coreinfo(videourl)
HProbe.print_coreinfo(ci)
if options.b_ts is True or options.b_vtype is True or options.b_vsize is True:
fi_opts = list()
if options.b_ts:
fi_opts.append('ts')
if options.b_vtype:
fi_opts.append('pict_type')
if options.b_vsize:
fi_opts.append('vframe_size')
dictFrameInfo = HProbe.get_frameinfo(videourl, fi_opts, duration_sec=options.duration)
if options.b_ts is True:
HProbe.print_ts(dictFrameInfo)
if options.b_nodraw is False:
HProbe.draw_frame_ts(dictFrameInfo)
if options.b_vtype is True:
HProbe.print_vtype(dictFrameInfo)
if options.b_nodraw is False:
HProbe.draw_frame_vtype(dictFrameInfo)
if options.b_vsize is True:
HProbe.print_vframesize(dictFrameInfo)
if options.b_nodraw is False:
HProbe.draw_vframesize(dictFrameInfo)
HProbe.print_vframe()
def main():
print("probe.py : format and visualize ffprobe's output \n"
"Help: python3 main.py -h\n")
parse = optparse.OptionParser(usage='"usage:%prog [options] videoURL"', version="%prog 1.0.2")
# parse.add_option('-q', '--qp', dest='user', action='store', type=str, metavar='user', help='Enter User Name!!')
parse.add_option('--qp', dest='b_qp', action='store_true', default=False,
help="show video QP, very very slow, I suggest using 'nohup' execute this mode")
parse.add_option('--vframesize', dest='b_vsize', action='store_true', default=False, help='show video frame size')
parse.add_option('--skip_frame', action='store', dest='skip_frame', type='string', default="default",
help="which frame will be skip when count QP, legal value: none, default, noref, bidir, nokey, nointra, all")
parse.add_option('--coreinfo', dest='b_ci', action='store_true', default=False, help="show core info of videoURL")
parse.add_option('--ts', dest='b_ts', action='store_true', default=False, help="show timestamp")
parse.add_option('--vtype', dest='b_vtype', action='store_true', default=False, help="show video frame type[IPB]")
parse.add_option('--nodraw', dest='b_nodraw', action='store_true', default=False,
help="don't draw figure")
parse.add_option('--duration', dest='duration', type='int', default=4, help="probe duration (second)")
options, args = parse.parse_args()
if (len(args) == 0):
return
probe_url(options, args[0])
if __name__ == "__main__":
main()