-
Notifications
You must be signed in to change notification settings - Fork 0
/
filesize_all_multiple_video.py
66 lines (58 loc) · 2.48 KB
/
filesize_all_multiple_video.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
import plotly.plotly as py
import plotly.graph_objs as go
# Style
symbols = ['x-thin-open','star-triangle-up','star-triangle-down','circle','hexagram-open','triangle-up-open','star-triangle-up','circle-open-dot','pentagon']
colors = {'vp9':'rgb(249,140,182)','tg':'rgb(133,202,93)','hm':'rgb(117,137,191)'}
sample = 0
files_names = []
# Load name of files
with open ('list', 'r') as f:
while True:
read_data = f.readline()
if not read_data:
break
files_names.append(read_data[:-1])
# Organise info in dictionaries like { videoN : { typoN : sizeN } }
video_titles = {}
for info in files_names:
video_name = "_".join(info.split(" ")[-1].split(".")[0].split("_")[:-1])
video_codec = info.split("_")[-1].split(".")[-1]
if (video_codec == 'webm'):
video_codec = 'vp9'
if (video_codec == 'hevc'):
video_codec = 'hm'
if (video_codec == 'bit'):
video_codec = 'tg'
video_type = info.split(" ")[-1].split(".")[0].split("_")[-1]
video_size = info.split(" ")[-5]
# print ("Name:{} Codec:{} Type:{} Size:{}".format(video_name, video_codec, video_type, video_size))
if not video_codec in video_titles:
video_titles[video_codec] = {}
if not video_type in video_titles[video_codec]:
video_titles[video_codec][video_type] = {}
video_titles[video_codec][video_type][video_name] = video_size
# print (video_titles)
# Human values
kilo = 1024
mega = 1024 * kilo
# Organise axis to plot and export in PNG Image
traces = []
for video_codec in sorted(video_titles):
color = colors[video_codec]
for video_type in sorted(video_titles[video_codec]):
x_axis = []
size = []
for video_name in sorted(video_titles[video_codec][video_type]):
x_axis.append(video_name)
size.append(video_titles[video_codec][video_type][video_name])
symbol = symbols[(sample)%(len(symbols))]
traces.append({'x' : x_axis, 'y' : size, 'marker':{"color": color, "size": 14, 'symbol': symbol, 'opacity':0.75}, "mode": "markers", "name": '{}-{}'.format(video_codec,video_type), "type":"scatter" })
sample += 1
data1 = []
for item in traces:
# print (item)
data1.append(item)
data = go.Data(data1)
# title = "{}".format(video_name)
title = "File Size (MB) - Videos and Modes"
py.image.save_as({'data':data, 'layout':{'title':title, 'xaxis':{'title': 'Video'}, 'yaxis':{'title':'Size (MB)'}}}, 'filesize_multiple_video', format='png', width=1280, height=720)